Fix a sad, sad bug that resulted in 100+MB config.json
This commit is contained in:
@@ -39,6 +39,10 @@ function run (state) {
|
|||||||
migrate_0_14_0(state.saved)
|
migrate_0_14_0(state.saved)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (semver.lt(version, '0.17.0')) {
|
||||||
|
migrate_0_17_0(state.saved)
|
||||||
|
}
|
||||||
|
|
||||||
// Config is now on the new version
|
// Config is now on the new version
|
||||||
state.saved.version = config.APP_VERSION
|
state.saved.version = config.APP_VERSION
|
||||||
}
|
}
|
||||||
@@ -145,3 +149,15 @@ function migrate_0_14_0 (saved) {
|
|||||||
delete ts.defaultPlayFileIndex
|
delete ts.defaultPlayFileIndex
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function migrate_0_17_0 (saved) {
|
||||||
|
// Fix a sad, sad bug that resulted in 100MB+ config.json files
|
||||||
|
saved.torrents.forEach(function (ts) {
|
||||||
|
if (!ts.files) return
|
||||||
|
ts.files.forEach(function (file) {
|
||||||
|
if (!file.audioInfo || !file.audioInfo.picture) return
|
||||||
|
// This contained a Buffer, which 30x'd in size when serialized to JSON
|
||||||
|
delete file.audioInfo.picture
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|||||||
@@ -348,9 +348,11 @@ function getAudioMetadata (infoHash, index) {
|
|||||||
const torrent = client.get(infoHash)
|
const torrent = client.get(infoHash)
|
||||||
const file = torrent.files[index]
|
const file = torrent.files[index]
|
||||||
musicmetadata(file.createReadStream(), function (err, info) {
|
musicmetadata(file.createReadStream(), function (err, info) {
|
||||||
if (err) return
|
if (err) return console.log('error getting audio metadata for ' + infoHash + ':' + index, err)
|
||||||
console.log('got audio metadata for %s: %o', file.name, info)
|
const { artist, album, albumartist, title, year, track, disk, genre } = info
|
||||||
ipc.send('wt-audio-metadata', infoHash, index, info)
|
const importantInfo = { artist, album, albumartist, title, year, track, disk, genre }
|
||||||
|
console.log('got audio metadata for %s: %o', file.name, importantInfo)
|
||||||
|
ipc.send('wt-audio-metadata', infoHash, index, importantInfo)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user