@xuda.io/drive_module 1.1.817 → 1.1.818
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.
- package/index.js +4 -88
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -869,8 +869,6 @@ exports.update_drive_file = async function (req, job_id, headers, file_obj) {
|
|
|
869
869
|
fse.copyFileSync(tempPath, target_dir);
|
|
870
870
|
}
|
|
871
871
|
|
|
872
|
-
let doc_ret;
|
|
873
|
-
|
|
874
872
|
doc.date_modified = Date.now();
|
|
875
873
|
|
|
876
874
|
const fs = require("fs").promises;
|
|
@@ -2589,101 +2587,19 @@ exports.update_drive_file_tags = async function (req, job_id, headers) {
|
|
|
2589
2587
|
const file_name = path.basename(file_path);
|
|
2590
2588
|
validate_drive_type(drive_type);
|
|
2591
2589
|
|
|
2592
|
-
let
|
|
2593
|
-
app_id,
|
|
2594
|
-
uid,
|
|
2595
|
-
drive_type,
|
|
2596
|
-
file_path,
|
|
2597
|
-
};
|
|
2598
|
-
const check_existing_file_ret = await module.exports.check_drive_file(
|
|
2599
|
-
check_req
|
|
2600
|
-
);
|
|
2590
|
+
let doc = await get_drive_doc(drive_type, app_id, uid, file_path, headers);
|
|
2601
2591
|
|
|
2602
2592
|
var target_file = file_name;
|
|
2603
2593
|
// const master_id = await _common.get_project_app_id(app_id, true);
|
|
2604
2594
|
|
|
2605
2595
|
let doc_ret;
|
|
2606
2596
|
|
|
2607
|
-
|
|
2608
|
-
|
|
2609
|
-
const app_id_master = await _common.get_project_app_id(app_id, true);
|
|
2610
|
-
doc_ret = await db_module.get_app_couch_doc(app_id_master, target_file);
|
|
2611
|
-
|
|
2612
|
-
break;
|
|
2613
|
-
}
|
|
2614
|
-
case "workspace": {
|
|
2615
|
-
const app_id_reference = await _common.get_project_app_id(app_id);
|
|
2616
|
-
doc_ret = await db_module.get_app_couch_doc(
|
|
2617
|
-
app_id_reference,
|
|
2618
|
-
check_existing_file_ret.duplicates[0]._id
|
|
2619
|
-
);
|
|
2620
|
-
|
|
2621
|
-
break;
|
|
2622
|
-
}
|
|
2623
|
-
|
|
2624
|
-
case "user":
|
|
2625
|
-
doc_ret = await db_module.get_couch_doc(
|
|
2626
|
-
"xuda_drive",
|
|
2627
|
-
check_existing_file_ret.duplicates[0]._id
|
|
2628
|
-
);
|
|
2629
|
-
|
|
2630
|
-
break;
|
|
2631
|
-
|
|
2632
|
-
default:
|
|
2633
|
-
break;
|
|
2634
|
-
}
|
|
2635
|
-
var doc = {};
|
|
2636
|
-
if (doc_ret.code > -1) {
|
|
2637
|
-
doc = doc_ret.data;
|
|
2638
|
-
doc.date_modified = Date.now();
|
|
2639
|
-
} else {
|
|
2640
|
-
if (drive_type === "studio") {
|
|
2641
|
-
const ext = path.extname(file_name).toLowerCase();
|
|
2642
|
-
doc = {
|
|
2643
|
-
_id: target_file,
|
|
2644
|
-
docType: `${drive_type}_drive`,
|
|
2645
|
-
stat: 3,
|
|
2646
|
-
originalname: file_name,
|
|
2647
|
-
uid,
|
|
2648
|
-
type: "file",
|
|
2649
|
-
date_created: Date.now(),
|
|
2650
|
-
ip: headers["cf-connecting-ip"],
|
|
2651
|
-
country: headers["cf-ipcountry"],
|
|
2652
|
-
file_ext: ext,
|
|
2653
|
-
is_archive: _conf.archive_drive_ext.includes(ext) ? true : false,
|
|
2654
|
-
drive_type,
|
|
2655
|
-
};
|
|
2656
|
-
} else {
|
|
2657
|
-
throw new Error("file not found");
|
|
2658
|
-
}
|
|
2659
|
-
}
|
|
2597
|
+
doc = doc_ret.data;
|
|
2598
|
+
doc.date_modified = Date.now();
|
|
2660
2599
|
|
|
2661
2600
|
doc.tags = tags;
|
|
2662
|
-
let save_ret;
|
|
2663
2601
|
|
|
2664
|
-
|
|
2665
|
-
case "workspace":
|
|
2666
|
-
case "studio":
|
|
2667
|
-
const app_id_reference = await _common.get_project_app_id(app_id);
|
|
2668
|
-
save_ret = await db_module.save_app_couch_doc(app_id_reference, doc);
|
|
2669
|
-
break;
|
|
2670
|
-
|
|
2671
|
-
case "user":
|
|
2672
|
-
save_ret = await db_module.save_couch_doc("xuda_drive", doc);
|
|
2673
|
-
break;
|
|
2674
|
-
|
|
2675
|
-
default:
|
|
2676
|
-
break;
|
|
2677
|
-
}
|
|
2678
|
-
|
|
2679
|
-
if (save_ret.code < 0) {
|
|
2680
|
-
throw new Error(save_ret.data);
|
|
2681
|
-
}
|
|
2682
|
-
|
|
2683
|
-
return {
|
|
2684
|
-
code: 200,
|
|
2685
|
-
data: tags,
|
|
2686
|
-
};
|
|
2602
|
+
return await save_drive_doc(drive_type, app_id, doc);
|
|
2687
2603
|
} catch (err) {
|
|
2688
2604
|
return {
|
|
2689
2605
|
code: -200,
|