ensure Posters/ folder exists
This commit is contained in:
@@ -6,7 +6,7 @@ module.exports = {
|
|||||||
APP_NAME: 'WebTorrent',
|
APP_NAME: 'WebTorrent',
|
||||||
|
|
||||||
CONFIG_PATH: applicationConfigPath('WebTorrent'),
|
CONFIG_PATH: applicationConfigPath('WebTorrent'),
|
||||||
CONFIG_POSTER_PATH: path.join(applicationConfigPath('WebTorrent'), 'posters'),
|
CONFIG_POSTER_PATH: path.join(applicationConfigPath('WebTorrent'), 'Posters'),
|
||||||
|
|
||||||
INDEX: 'file://' + path.join(__dirname, 'renderer', 'index.html'),
|
INDEX: 'file://' + path.join(__dirname, 'renderer', 'index.html'),
|
||||||
|
|
||||||
|
|||||||
@@ -290,6 +290,7 @@ function loadState (callback) {
|
|||||||
state.saved.torrents.forEach(function (torrentSummary) {
|
state.saved.torrents.forEach(function (torrentSummary) {
|
||||||
if (torrentSummary.displayName) torrentSummary.name = torrentSummary.displayName
|
if (torrentSummary.displayName) torrentSummary.name = torrentSummary.displayName
|
||||||
})
|
})
|
||||||
|
saveState()
|
||||||
|
|
||||||
if (callback) callback()
|
if (callback) callback()
|
||||||
})
|
})
|
||||||
@@ -461,12 +462,15 @@ function generateTorrentPoster (torrent, torrentSummary) {
|
|||||||
torrentPoster(torrent, function (err, buf) {
|
torrentPoster(torrent, function (err, buf) {
|
||||||
if (err) return onWarning(err)
|
if (err) return onWarning(err)
|
||||||
// save it for next time
|
// save it for next time
|
||||||
var posterFilePath = path.join(config.CONFIG_POSTER_PATH, torrent.infoHash + '.jpg')
|
fs.mkdir(config.CONFIG_POSTER_PATH, function (err) {
|
||||||
fs.writeFile(posterFilePath, buf, function (err) {
|
|
||||||
if (err) return onWarning(err)
|
if (err) return onWarning(err)
|
||||||
// show the poster
|
var posterFilePath = path.join(config.CONFIG_POSTER_PATH, torrent.infoHash + '.jpg')
|
||||||
torrentSummary.posterURL = 'file:///' + posterFilePath
|
fs.writeFile(posterFilePath, buf, function (err) {
|
||||||
update()
|
if (err) return onWarning(err)
|
||||||
|
// show the poster
|
||||||
|
torrentSummary.posterURL = 'file:///' + posterFilePath
|
||||||
|
update()
|
||||||
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user