index.js 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. const fs = require('fs-extra');
  2. const crypto = require('crypto');
  3. const utils = require('../utils');
  4. class LibSharedStorage {
  5. constructor() {
  6. this.readingFiles = false;
  7. }
  8. async init(config) {
  9. this.config = config;
  10. this.lssDir = `${config.sharedDir}/lss`;
  11. await fs.ensureDir(this.lssDir);
  12. }
  13. storageNameToPath(storageFilename) {
  14. if (storageFilename.length < 4)
  15. throw new Error('LibSharedStorage: ошибка в имени файла');
  16. return `${storageFilename.substr(0, 2)}/${storageFilename.substr(2, 2)}/${storageFilename}`;
  17. }
  18. async filenameToStoragePath(filename) {
  19. const base36hash = utils.toBase36(await utils.getFileHash(filename, 'sha1'));
  20. }
  21. async checkFile(filename) {
  22. }
  23. async addFile(filename, desc) {
  24. }
  25. async addFileFromArchive(archiveFilename, deompFiles, desc) {
  26. }
  27. async updateFileDesc(storagePath, desc) {
  28. }
  29. async getAuthorPath(authorName) {
  30. }
  31. async checkAuthor(authorName) {
  32. }
  33. async addAuthor(authorName, desc) {
  34. }
  35. async readFiles(callback) {
  36. }
  37. async stopReadFiles() {
  38. }
  39. async getFilesStatistic() {
  40. }
  41. }
  42. module.exports = LibSharedStorage;