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);