diff --git a/bin/cleanup.js b/bin/cleanup.js index f99bc2a2..72739b64 100755 --- a/bin/cleanup.js +++ b/bin/cleanup.js @@ -5,15 +5,13 @@ * Useful for developers. */ -var applicationConfigPath = require('application-config-path') var config = require('../config') var os = require('os') var path = require('path') var pathExists = require('path-exists') var rimraf = require('rimraf') -var tmpPath = path.join(pathExists.sync('/tmp') ? '/tmp' : os.tmpDir(), 'webtorrent') -var configPath = applicationConfigPath(config.APP_NAME) +rimraf.sync(config.CONFIG_PATH) -rimraf.sync(configPath) +var tmpPath = path.join(pathExists.sync('/tmp') ? '/tmp' : os.tmpDir(), 'webtorrent') rimraf.sync(tmpPath) diff --git a/config.js b/config.js index 311e0e90..fe0ed762 100644 --- a/config.js +++ b/config.js @@ -1,9 +1,15 @@ +var applicationConfigPath = require('application-config-path') var path = require('path') module.exports = { - APP_NAME: 'WebTorrent', APP_ICON: path.join(__dirname, 'static', 'WebTorrent.png'), + APP_NAME: 'WebTorrent', + + CONFIG_PATH: applicationConfigPath('WebTorrent'), + CONFIG_POSTER_PATH: path.join(applicationConfigPath('WebTorrent'), 'posters'), + INDEX: 'file://' + path.join(__dirname, 'renderer', 'index.html'), + SOUND_ADD: 'file://' + path.join(__dirname, 'static', 'sound', 'add.wav'), SOUND_DELETE: 'file://' + path.join(__dirname, 'static', 'sound', 'delete.wav'), SOUND_DISABLE: 'file://' + path.join(__dirname, 'static', 'sound', 'disable.wav'), diff --git a/renderer/index.js b/renderer/index.js index 6f79b993..f27e1fb6 100644 --- a/renderer/index.js +++ b/renderer/index.js @@ -1,7 +1,6 @@ console.time('init') var cfg = require('application-config')('WebTorrent') -var cfgDirectory = require('application-config-path')('WebTorrent') var createTorrent = require('create-torrent') var dragDrop = require('drag-drop') var electron = require('electron') @@ -462,7 +461,7 @@ function generateTorrentPoster (torrent, torrentSummary) { torrentPoster(torrent, function (err, buf) { if (err) return onWarning(err) // save it for next time - var posterFilePath = path.join(cfgDirectory, torrent.infoHash + '.jpg') + 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 diff --git a/renderer/state.js b/renderer/state.js index fb0d2ba2..312233ec 100644 --- a/renderer/state.js +++ b/renderer/state.js @@ -46,7 +46,7 @@ module.exports = { * * Config path: * - * OS XDG ~/Library/Application Support/WebTorrent/config.json + * OS X ~/Library/Application Support/WebTorrent/config.json * Linux (XDG) $XDG_CONFIG_HOME/WebTorrent/config.json * Linux (Legacy) ~/.config/WebTorrent/config.json * Windows (> Vista) %LOCALAPPDATA%/WebTorrent/config.json