|
@@ -1,6 +1,5 @@
|
|
const fs = require('fs-extra');
|
|
const fs = require('fs-extra');
|
|
const path = require('path');
|
|
const path = require('path');
|
|
-const crypto = require('crypto');
|
|
|
|
|
|
|
|
const workerState = require('./workerState');
|
|
const workerState = require('./workerState');
|
|
const FileDownloader = require('./FileDownloader');
|
|
const FileDownloader = require('./FileDownloader');
|
|
@@ -9,6 +8,8 @@ const BookConverter = require('./BookConverter');
|
|
const utils = require('./utils');
|
|
const utils = require('./utils');
|
|
const log = require('./getLogger').getLog();
|
|
const log = require('./getLogger').getLog();
|
|
|
|
|
|
|
|
+const LibSharedStorage = require('./LibSharedStorage');
|
|
|
|
+
|
|
let singleCleanExecute = false;
|
|
let singleCleanExecute = false;
|
|
|
|
|
|
class ReaderWorker {
|
|
class ReaderWorker {
|
|
@@ -30,6 +31,12 @@ class ReaderWorker {
|
|
this.periodicCleanDir(this.config.uploadDir, this.config.maxUploadPublicDirSize, 60*60*1000);//1 раз в час
|
|
this.periodicCleanDir(this.config.uploadDir, this.config.maxUploadPublicDirSize, 60*60*1000);//1 раз в час
|
|
singleCleanExecute = true;
|
|
singleCleanExecute = true;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ (async() => {
|
|
|
|
+ const libSharedStorage = new LibSharedStorage();
|
|
|
|
+ await libSharedStorage.init(config);
|
|
|
|
+ libSharedStorage.filenameToStoragePath('/home/sizikov/Downloads/15/1.zip');
|
|
|
|
+ })();
|
|
}
|
|
}
|
|
|
|
|
|
async loadBook(opts, wState) {
|
|
async loadBook(opts, wState) {
|
|
@@ -117,10 +124,7 @@ class ReaderWorker {
|
|
}
|
|
}
|
|
|
|
|
|
async saveFile(file) {
|
|
async saveFile(file) {
|
|
- const buf = await fs.readFile(file.path);
|
|
|
|
-
|
|
|
|
- const hash = crypto.createHash('sha256').update(buf).digest('hex');
|
|
|
|
-
|
|
|
|
|
|
+ const hash = await utils.getFileHash(file.path, 'sha256', 'hex');
|
|
const outFilename = `${this.config.uploadDir}/${hash}`;
|
|
const outFilename = `${this.config.uploadDir}/${hash}`;
|
|
|
|
|
|
if (!await fs.pathExists(outFilename)) {
|
|
if (!await fs.pathExists(outFilename)) {
|