2 Commits

Author SHA1 Message Date
Godzil
a01f3cd09c 1.1.18: Fix issue #19 2017-02-16 23:05:16 +00:00
Godzil
ed4f398062 Fix #19, better to check if a file exist before trying to copy it 😂 2017-02-16 23:03:43 +00:00
2 changed files with 20 additions and 2 deletions

View File

@@ -12,7 +12,7 @@
"type": "git",
"url": "git://github.com/Godzil/crunchyroll.js.git"
},
"version": "1.1.17",
"version": "1.1.18",
"bin": {
"crunchy": "./bin/crunchy"
},

View File

@@ -9,6 +9,21 @@ import url = require('url');
import log = require('./log');
const persistent = '.crpersistent';
/**
* Check if a file exist..
*/
function fileExist(path: string)
{
try
{
fs.statSync(path);
return true;
} catch (e)
{
return false;
}
}
/**
* Streams the series to disk.
*/
@@ -17,7 +32,10 @@ export default function(config: IConfig, address: string, done: (err: Error) =>
const persistentPath = path.join(config.output || process.cwd(), persistent);
/* Make a backup of the persistent file in case of */
fse.copySync(persistentPath, persistentPath + '.backup');
if (fileExist(persistentPath))
{
fse.copySync(persistentPath, persistentPath + '.backup');
}
fs.readFile(persistentPath, 'utf8', (err: Error, contents: string) =>
{