|
@@ -336,12 +336,21 @@ router.route("/deleteFolder").all(async (req, res, next) => {
|
|
|
//mode的处理
|
|
|
if (req.body[0]) {
|
|
|
try {
|
|
|
- let folderids = decodeURIComponent(req.body[0].folderids).split(",")
|
|
|
- let ids = req.body[0].ids
|
|
|
+ const folderids = decodeURIComponent(req.body[0].folderids).split(",");
|
|
|
+ const ids = req.body[0].ids;
|
|
|
+
|
|
|
+ // 并行处理文件夹下的文件删除和文件夹删除
|
|
|
+ await Promise.all(folderids.map(async folderid => {
|
|
|
+ const files = await client.collections.listDocuments({ id: folderid, offset: 0, limit: 999 });
|
|
|
+ await Promise.all(files.results.map(file =>
|
|
|
+ client.collections.removeDocument({ id: folderid, documentId: file.id })
|
|
|
+ ));
|
|
|
+ }));
|
|
|
+
|
|
|
await Promise.all(folderids.map(folderid => client.collections.delete({ id: folderid })));
|
|
|
- p = [ids];
|
|
|
- p.unshift(_mysqlLabor[0], _mysqlLabor[1], "deleteFolder");
|
|
|
- mysql.usselect(p, async function (ret) {
|
|
|
+
|
|
|
+ const params = [_mysqlLabor[0], _mysqlLabor[1], "deleteFolder", ids];
|
|
|
+ mysql.usselect(params, async function (ret) {
|
|
|
res.end(JSON.stringify(ret));
|
|
|
});
|
|
|
|