mirror of
https://github.com/NuSkooler/enigma-bbs.git
synced 2025-06-11 23:24:43 +02:00
Fix loading order on fb info
This commit is contained in:
parent
6717cd5179
commit
5c58fd2cfa
1 changed files with 11 additions and 11 deletions
|
@ -139,23 +139,23 @@ function dumpFileInfo(shaOrFileId, cb) {
|
||||||
|
|
||||||
async.waterfall(
|
async.waterfall(
|
||||||
[
|
[
|
||||||
function getBySha(callback) {
|
function getByFileId(callback) {
|
||||||
FileEntry.findFileBySha(shaOrFileId, (err, fileEntry) => {
|
const fileId = parseInt(shaOrFileId);
|
||||||
return callback(null, fileEntry);
|
if(!/^[0-9]+$/.test(shaOrFileId) || isNaN(fileId)) {
|
||||||
|
return callback(null, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
const fileEntry = new FileEntry();
|
||||||
|
fileEntry.load(fileId, () => {
|
||||||
|
return callback(null, fileEntry); // try sha
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
function getByFileId(fileEntry, callback) {
|
function getBySha(fileEntry, callback) {
|
||||||
if(fileEntry) {
|
if(fileEntry) {
|
||||||
return callback(null, fileEntry); // already got it by sha
|
return callback(null, fileEntry); // already got it by sha
|
||||||
}
|
}
|
||||||
|
|
||||||
const fileId = parseInt(shaOrFileId);
|
FileEntry.findFileBySha(shaOrFileId, (err, fileEntry) => {
|
||||||
if(isNaN(fileId)) {
|
|
||||||
return callback(Errors.DoesNotExist('Not found'));
|
|
||||||
}
|
|
||||||
|
|
||||||
fileEntry = new FileEntry();
|
|
||||||
fileEntry.load(shaOrFileId, err => {
|
|
||||||
return callback(err, fileEntry);
|
return callback(err, fileEntry);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue