mirror of https://github.com/calzoneman/sync.git
Fix startup issue
This commit is contained in:
parent
33f775051d
commit
17aad006f7
|
@ -18,11 +18,6 @@ module.exports = {
|
||||||
exists || fs.mkdir(chandumppath);
|
exists || fs.mkdir(chandumppath);
|
||||||
});
|
});
|
||||||
|
|
||||||
var statepath = path.join(__dirname, "../state");
|
|
||||||
fs.exists(statepath, function (exists) {
|
|
||||||
exists || fs.mkdir(statepath);
|
|
||||||
});
|
|
||||||
|
|
||||||
var gdvttpath = path.join(__dirname, "../google-drive-subtitles");
|
var gdvttpath = path.join(__dirname, "../google-drive-subtitles");
|
||||||
fs.exists(gdvttpath, function (exists) {
|
fs.exists(gdvttpath, function (exists) {
|
||||||
exists || fs.mkdir(gdvttpath);
|
exists || fs.mkdir(gdvttpath);
|
||||||
|
|
|
@ -2,6 +2,7 @@ import path from 'path';
|
||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
import crypto from 'crypto';
|
import crypto from 'crypto';
|
||||||
|
|
||||||
|
const STATE_FOLDER_PATH = path.resolve(__dirname, '..', '..', '..', 'state');
|
||||||
const SALT_PATH = path.resolve(__dirname, '..', '..', '..', 'state', 'ipsessionsalt.json');
|
const SALT_PATH = path.resolve(__dirname, '..', '..', '..', 'state', 'ipsessionsalt.json');
|
||||||
|
|
||||||
const NO_EXPIRATION = new Date('Fri, 31 Dec 9999 23:59:59 GMT');
|
const NO_EXPIRATION = new Date('Fri, 31 Dec 9999 23:59:59 GMT');
|
||||||
|
@ -10,6 +11,13 @@ try {
|
||||||
SALT = require(SALT_PATH);
|
SALT = require(SALT_PATH);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
SALT = crypto.randomBytes(32).toString('base64');
|
SALT = crypto.randomBytes(32).toString('base64');
|
||||||
|
try {
|
||||||
|
fs.mkdirSync(STATE_FOLDER_PATH);
|
||||||
|
} catch (error) {
|
||||||
|
if (error.code !== 'EEXIST') {
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
}
|
||||||
fs.writeFileSync(SALT_PATH, JSON.stringify(SALT));
|
fs.writeFileSync(SALT_PATH, JSON.stringify(SALT));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue