feat: move all user profile pics to folder, closes #12449 (#12450)

* feat: move all user profile pics to folder

get rid of glob delete and just delete the uid-{uid} folder when deleting user images

* when exporting user uploads add all profile uploads

* uid check
This commit is contained in:
Barış Soner Uşaklı
2024-03-28 16:50:56 -04:00
committed by GitHub
parent aef3ea18cf
commit 8f9ac5c17a
5 changed files with 99 additions and 17 deletions

View File

@@ -18,8 +18,7 @@ const plugins = require('../plugins');
const events = require('../events');
const translator = require('../translator');
const sockets = require('../socket.io');
// const api = require('.');
const utils = require('../utils');
const usersAPI = module.exports;
@@ -686,6 +685,9 @@ usersAPI.generateExport = async (caller, { uid, type }) => {
if (!validTypes.includes(type)) {
throw new Error('[[error:invalid-data]]');
}
if (!utils.isNumber(uid) || !(parseInt(uid, 10) > 0)) {
throw new Error('[[error:invalid-uid]]');
}
const count = await db.incrObjectField('locks', `export:${uid}${type}`);
if (count > 1) {
throw new Error('[[error:already-exporting]]');