Поправки
This commit is contained in:
@@ -30,6 +30,8 @@ class MegaStorage {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async nameHash(filename) {
|
async nameHash(filename) {
|
||||||
|
if (!this.inited)
|
||||||
|
throw new Error('MegaStorage::not inited');
|
||||||
const hash = utils.toBase36(await utils.getFileHash(filename, 'sha1'));
|
const hash = utils.toBase36(await utils.getFileHash(filename, 'sha1'));
|
||||||
const hashPath = `${hash.substr(0, 2)}/${hash.substr(2, 2)}/${hash}`;
|
const hashPath = `${hash.substr(0, 2)}/${hash.substr(2, 2)}/${hash}`;
|
||||||
const fullHashPath = `${this.megaStorageDir}/${hashPath}`;
|
const fullHashPath = `${this.megaStorageDir}/${hashPath}`;
|
||||||
@@ -48,6 +50,8 @@ class MegaStorage {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async addFile(nameHash, desc = null, force = false) {
|
async addFile(nameHash, desc = null, force = false) {
|
||||||
|
if (!this.inited)
|
||||||
|
throw new Error('MegaStorage::not inited');
|
||||||
if (await this.checkFileExists(nameHash) && !force)
|
if (await this.checkFileExists(nameHash) && !force)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@@ -90,6 +94,8 @@ class MegaStorage {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async startFindFiles(callback, dir) {
|
async startFindFiles(callback, dir) {
|
||||||
|
if (!this.inited)
|
||||||
|
throw new Error('MegaStorage::not inited');
|
||||||
this.readingFiles = true;
|
this.readingFiles = true;
|
||||||
try {
|
try {
|
||||||
return await this._findFiles(callback, dir);
|
return await this._findFiles(callback, dir);
|
||||||
@@ -103,6 +109,8 @@ class MegaStorage {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async getStats(gather = false) {
|
async getStats(gather = false) {
|
||||||
|
if (!this.inited)
|
||||||
|
throw new Error('MegaStorage::not inited');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user