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