@xuda.io/drive_module 1.1.476 → 1.1.478

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/index.js +31 -1
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -497,6 +497,19 @@ exports.delete_drive_files = async function (req) {
497
497
 
498
498
  const ret = rimraf.sync(file.path); // delete the file
499
499
  if (doc_ret.code > -1) {
500
+ if (doc_ret.data.type === "directory") {
501
+ const docs = await get_folder_docs(
502
+ path.basename(file.path),
503
+ drive_type,
504
+ null
505
+ );
506
+ for await (let doc of docs) {
507
+ doc._deleted = true;
508
+
509
+ await db_module.save_couch_doc("xuda_drive", doc);
510
+ }
511
+ }
512
+
500
513
  doc_ret.data._deleted = true;
501
514
  save_ret = await db_module.save_app_couch_doc(
502
515
  app_id_master,
@@ -545,7 +558,24 @@ exports.delete_drive_files = async function (req) {
545
558
 
546
559
  case "user": {
547
560
  doc_ret = await db_module.get_couch_doc("xuda_drive", file.name);
548
- await module.exports.delete_file_from_bucket(doc_ret.data.bucket);
561
+ if (doc_ret.data.type === "file") {
562
+ await module.exports.delete_file_from_bucket(doc_ret.data.bucket);
563
+ }
564
+ if (doc_ret.data.type === "directory") {
565
+ const docs = await get_folder_docs(
566
+ path.basename(file.path),
567
+ drive_type,
568
+ null
569
+ );
570
+ for await (let doc of docs) {
571
+ if (doc.type === "file") {
572
+ await module.exports.delete_file_from_bucket(doc.bucket);
573
+ }
574
+ doc.ts = Date.now();
575
+ doc.stat = 4;
576
+ await db_module.save_couch_doc("xuda_drive", doc);
577
+ }
578
+ }
549
579
  doc_ret.data.ts = Date.now();
550
580
  doc_ret.data.stat = 4;
551
581
  save_ret = await db_module.save_couch_doc("xuda_drive", doc_ret.data);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xuda.io/drive_module",
3
- "version": "1.1.476",
3
+ "version": "1.1.478",
4
4
  "description": "Xuda Drive Server Module",
5
5
  "main": "index.js",
6
6
  "dependencies": {