Fix cross-device rename
This commit is contained in:
parent
37760f5639
commit
051f95fee7
@ -72,4 +72,15 @@ function askAsync (rl, q) {
|
||||
})
|
||||
}
|
||||
|
||||
export default {getFiles, promiseExec, askAsync, insertDB}
|
||||
function copyAsync (fsrc, fdst) {
|
||||
return new Promise((resolve, reject) => {
|
||||
let source = fs.createReadStream(path.resolve(fsrc))
|
||||
let dest = fs.createWriteStream(path.resolve(fdst))
|
||||
|
||||
source.pipe(dest)
|
||||
source.on('end', resolve)
|
||||
source.on('error', reject)
|
||||
})
|
||||
}
|
||||
|
||||
export default {getFiles, promiseExec, askAsync, insertDB, copyAsync}
|
||||
|
@ -49,7 +49,8 @@ async function download (furl) {
|
||||
}
|
||||
|
||||
let fn = path.join(musicdir, filename)
|
||||
await fs.rename(file.source, fn)
|
||||
await asn.copyAsync(file.source, fn)
|
||||
await fs.unlink(file.source)
|
||||
|
||||
let id3 = await asn.promiseExec(`id3 -a "${clean.artist}" -t "${clean.title}" "${fn}"`)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user