Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
enableProgressBar() {
/* istanbul ignore next */
if (this.options.progress !== false) {
log.enableProgress();
}
}
export default function pls (roots) {
log.enableProgress()
return scanAlbums(roots)
.then((albums) => {
log.disableProgress()
console.log(makePlaylist([...albums].sort(byDate)))
})
}
export default function inspect (files) {
const progressGroups = new Map()
log.silly('inspect', 'files', files)
log.enableProgress()
return Bluebird.map(files, (path) => {
progressGroups.set(basename(path), log.newGroup(path))
return scan({ path }, progressGroups)
}).then((track) => {
log.disableProgress()
console.log(JSON.stringify(track, null, 2))
})
}
export default function pack (sources, destination, blockSize) {
log.enableProgress()
const getBlockSize = blockSizeFromPath(destination)
const sizeDestination = getBlockSize
.then((blockBytes) => [
blockBytes,
freeBlocksFromPath(destination, blockBytes)
]).all()
return sizeDestination.spread((blockBytes, { available }) => {
return scanAlbums(sources, progressGroups).then((albums) => {
const { included, discarded } = optimize(albums, available, blockBytes)
let usedBlocks = 0
for (let album of included.sort(bySize)) {
log.silly(
export default function showAlbums (files = [], roots = [], progressGroups) {
log.enableProgress()
roots = files.concat(roots)
log.silly('showAlbums', 'scanning', roots)
const sorted = scanAlbums(roots, progressGroups).then((albums) => {
log.silly('scanAlbums', 'albums', albums)
const sorted = [...albums].sort(byDate)
log.silly('scanAlbums', 'sorted', sorted.map((a) => '[' + a.date + '] ' + a.name))
log.disableProgress()
return sorted
})
return sorted.then(report)
}
export default function unpack (target = {}, staging, archiveRoot, playlist) {
log.enableProgress()
const { roots = [], pattern, files = [] } = target
log.silly('unpack', 'initial files', files)
let paths
if (roots.length && pattern) {
paths = Bluebird.map(
roots,
(path) => glob(join(path, pattern))
).then((lists) => lists.reduce((a, c) => a.concat(c), files))
} else {
paths = Bluebird.resolve(files)
}
paths = paths.then((expanded) => {
log.silly('unpack', 'expanded files', expanded)
return expanded
export default function scanArtists (files = [], roots = [], progressGroups = new Map()) {
log.enableProgress()
roots = files.concat(roots)
return Bluebird.mapSeries(
roots,
(root) => {
log.verbose('scanArtists', 'processing', root)
const artists = readFSMetadata(root).map(
(info) => scan(info, progressGroups),
{ concurrency: 2 }
).then(tracksToArtists)
return artists.then((artists) => [root, artists])
}
).then(report)
}
export default function optimizeAlbums (
files = [],
roots = [],
blockSize,
capacity) {
const entities = files.concat(roots)
log.enableProgress()
log.silly('optimizeAlbums', 'entities', entities)
return scanAlbums(entities)
.then((albums) => {
log.disableProgress()
calculate([...albums], blockSize, capacity)
})
}
export default function audit (roots) {
log.silly('audit', 'files', roots)
log.enableProgress()
return scanAlbums(roots)
.then((albums) => {
log.disableProgress()
log.silly('audit', 'albums', albums)
for (let album of albums) {
const id = album.artist.name + ': ' + album.name + ' /'
for (let warning of auditAlbum(album)) log.warn('audit', id, warning)
}
})
}