ensure Posters/ folder exists

This commit is contained in:
Feross Aboukhadijeh
2016-03-19 16:30:36 -07:00
parent 7738aa2f16
commit 75841afcb5
2 changed files with 10 additions and 6 deletions

View File

@@ -6,7 +6,7 @@ module.exports = {
APP_NAME: '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'),

View File

@@ -290,6 +290,7 @@ function loadState (callback) {
state.saved.torrents.forEach(function (torrentSummary) {
if (torrentSummary.displayName) torrentSummary.name = torrentSummary.displayName
})
saveState()
if (callback) callback()
})
@@ -461,12 +462,15 @@ function generateTorrentPoster (torrent, torrentSummary) {
torrentPoster(torrent, function (err, buf) {
if (err) return onWarning(err)
// save it for next time
var posterFilePath = path.join(config.CONFIG_POSTER_PATH, torrent.infoHash + '.jpg')
fs.writeFile(posterFilePath, buf, function (err) {
fs.mkdir(config.CONFIG_POSTER_PATH, function (err) {
if (err) return onWarning(err)
// show the poster
torrentSummary.posterURL = 'file:///' + posterFilePath
update()
var posterFilePath = path.join(config.CONFIG_POSTER_PATH, torrent.infoHash + '.jpg')
fs.writeFile(posterFilePath, buf, function (err) {
if (err) return onWarning(err)
// show the poster
torrentSummary.posterURL = 'file:///' + posterFilePath
update()
})
})
})
}