mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-08 06:55:46 +01:00
fix updrade error if file is not found closes #6485
This commit is contained in:
@@ -73,9 +73,7 @@ module.exports = function (Posts) {
|
|||||||
|
|
||||||
Posts.uploads.associate = function (pid, filePaths, callback) {
|
Posts.uploads.associate = function (pid, filePaths, callback) {
|
||||||
// Adds an upload to a post's sorted set of uploads
|
// Adds an upload to a post's sorted set of uploads
|
||||||
const now = Date.now();
|
|
||||||
filePaths = !Array.isArray(filePaths) ? [filePaths] : filePaths;
|
filePaths = !Array.isArray(filePaths) ? [filePaths] : filePaths;
|
||||||
const scores = filePaths.map(() => now);
|
|
||||||
|
|
||||||
async.filter(filePaths, function (filePath, next) {
|
async.filter(filePaths, function (filePath, next) {
|
||||||
// Only process files that exist
|
// Only process files that exist
|
||||||
@@ -83,10 +81,12 @@ module.exports = function (Posts) {
|
|||||||
next(null, !err);
|
next(null, !err);
|
||||||
});
|
});
|
||||||
}, function (err, filePaths) {
|
}, function (err, filePaths) {
|
||||||
let methods = [async.apply(db.sortedSetAdd.bind(db), 'post:' + pid + ':uploads', scores, filePaths)];
|
|
||||||
if (err) {
|
if (err) {
|
||||||
return callback(err);
|
return callback(err);
|
||||||
}
|
}
|
||||||
|
const now = Date.now();
|
||||||
|
const scores = filePaths.map(() => now);
|
||||||
|
let methods = [async.apply(db.sortedSetAdd.bind(db), 'post:' + pid + ':uploads', scores, filePaths)];
|
||||||
|
|
||||||
methods = methods.concat(filePaths.map(path => async.apply(db.sortedSetAdd.bind(db), 'upload:' + md5(path) + ':pids', now, pid)));
|
methods = methods.concat(filePaths.map(path => async.apply(db.sortedSetAdd.bind(db), 'upload:' + md5(path) + ':pids', now, pid)));
|
||||||
async.parallel(methods, function (err) {
|
async.parallel(methods, function (err) {
|
||||||
|
|||||||
Reference in New Issue
Block a user