Skip to content

Node.js based forum software built for the modern web

feat: make upload scores descending for ordering

Barış Soner Uşaklı3ec44d640d62
diff --git a/src/posts/uploads.js b/src/posts/uploads.js
index 3ab2a6aeb4..12564d0f17 100644
--- a/src/posts/uploads.js
+++ b/src/posts/uploads.js
@@ -163,7 +163,7 @@ module.exports = function (Posts) {
filePaths = await _filterValidPaths(filePaths); // Only process files that exist and are within uploads directory
const now = Date.now();
- const scores = filePaths.map(() => now);
+ const scores = filePaths.map((p, i) => now + i);
const bulkAdd = filePaths.map(path => [`upload:${md5(path)}:pids`, now, pid]);
await Promise.all([
db.sortedSetAdd(`post:${pid}:uploads`, scores, filePaths),