A bit of code reformating and add an option to regenerate the .crpersistant file in case it become corrupted and Crunchy try to redownload everything.

This commit is contained in:
Godzil
2018-06-01 20:37:10 +01:00
parent 6ad4cbed0a
commit 849c7612aa
6 changed files with 109 additions and 45 deletions

View File

@@ -57,7 +57,8 @@ function fileExist(path: string)
{
fs.statSync(path);
return true;
} catch (e)
}
catch (e)
{
return false;
}
@@ -82,6 +83,13 @@ function download(config: IConfig, page: IEpisodePage, player: IEpisodePlayer, d
if (fileExist(filePath + '.mkv'))
{
let count = 0;
if (config.rebuildcrp)
{
log.warn('Adding \'' + fileName + '\' to the DB...');
return done(null, false);
}
log.warn('File \'' + fileName + '\' already exist...');
do
@@ -94,6 +102,11 @@ function download(config: IConfig, page: IEpisodePage, player: IEpisodePlayer, d
log.warn('Renaming to \'' + fileName + '\'...');
}
if (config.rebuildcrp)
{
return done(null, true);
}
mkdirp(path.dirname(filePath), (errM: Error) =>
{
if (errM)