From 8136c7b072db918bc3fe392fd07cc5232ce8bdd4 Mon Sep 17 00:00:00 2001 From: Book Pauk Date: Fri, 25 Oct 2019 21:18:09 +0700 Subject: [PATCH] =?UTF-8?q?=D0=9D=D0=B0=D1=87=D0=B0=D0=BB=D0=BE=20=D1=80?= =?UTF-8?q?=D0=B0=D0=B1=D0=BE=D1=82=D1=8B=20=D0=BD=D0=B0=D0=B4=20LibShared?= =?UTF-8?q?Storage?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/core/LibSharedStorage/index.js | 58 +++++++++++++++++++++++++++ server/index.js | 2 + 2 files changed, 60 insertions(+) create mode 100644 server/core/LibSharedStorage/index.js diff --git a/server/core/LibSharedStorage/index.js b/server/core/LibSharedStorage/index.js new file mode 100644 index 00000000..5178941a --- /dev/null +++ b/server/core/LibSharedStorage/index.js @@ -0,0 +1,58 @@ +const fs = require('fs-extra'); +const crypto = require('crypto'); + +const utils = require('../utils'); + +class LibSharedStorage { + constructor() { + this.readingFiles = false; + } + + async init(config) { + this.config = config; + this.lssDir = `${config.sharedDir}/lss`; + await fs.ensureDir(this.lssDir); + } + + storageNameToPath(storageFilename) { + if (storageFilename.length < 4) + throw new Error('LibSharedStorage: ошибка в имени файла'); + return `${storageFilename.substr(0, 2)}/${storageFilename.substr(2, 2)}/${storageFilename}`; + } + + async filenameToStoragePath(filename) { + const base36hash = utils.toBase36(await utils.getFileHash(filename, 'sha1')); + } + + async checkFile(filename) { + } + + async addFile(filename, desc) { + } + + async addFileFromArchive(archiveFilename, deompFiles, desc) { + } + + async updateFileDesc(storagePath, desc) { + } + + async getAuthorPath(authorName) { + } + + async checkAuthor(authorName) { + } + + async addAuthor(authorName, desc) { + } + + async readFiles(callback) { + } + + async stopReadFiles() { + } + + async getFilesStatistic() { + } +} + +module.exports = LibSharedStorage; \ No newline at end of file diff --git a/server/index.js b/server/index.js index 6006793a..a9ba67c2 100644 --- a/server/index.js +++ b/server/index.js @@ -16,6 +16,8 @@ const connManager = require('./db/connManager'); async function init() { await fs.ensureDir(config.dataDir); await fs.ensureDir(config.uploadDir); + await fs.ensureDir(config.sharedDir); + await fs.ensureDir(config.tempDir); await fs.emptyDir(config.tempDir);