@xuda.io/drive_module 1.1.771 → 1.1.773
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 +60 -1
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -2542,4 +2542,63 @@ setTimeout(async function () {
|
|
|
2542
2542
|
// );
|
|
2543
2543
|
}, 2000);
|
|
2544
2544
|
|
|
2545
|
-
const get_drive_doc = function (drive_type, app_id, uid, file_path) {
|
|
2545
|
+
const get_drive_doc = async function (drive_type, app_id, uid, file_path) {
|
|
2546
|
+
let check_req = {
|
|
2547
|
+
app_id,
|
|
2548
|
+
uid,
|
|
2549
|
+
drive_type,
|
|
2550
|
+
file_path,
|
|
2551
|
+
};
|
|
2552
|
+
const check_existing_file_ret = await module.exports.check_drive_file(
|
|
2553
|
+
check_req
|
|
2554
|
+
);
|
|
2555
|
+
|
|
2556
|
+
let doc_ret;
|
|
2557
|
+
|
|
2558
|
+
switch (drive_type) {
|
|
2559
|
+
case "studio": {
|
|
2560
|
+
const app_id_reference = await _common.get_project_app_id(app_id);
|
|
2561
|
+
doc_ret = await db_module.get_app_couch_doc(app_id_reference, file_path);
|
|
2562
|
+
break;
|
|
2563
|
+
}
|
|
2564
|
+
case "user":
|
|
2565
|
+
doc_ret = await db_module.get_couch_doc(
|
|
2566
|
+
"xuda_drive",
|
|
2567
|
+
check_existing_file_ret.duplicates[0]._id
|
|
2568
|
+
);
|
|
2569
|
+
break;
|
|
2570
|
+
|
|
2571
|
+
case "workspace": {
|
|
2572
|
+
const app_id_reference = await _common.get_project_app_id(app_id);
|
|
2573
|
+
doc_ret = await db_module.get_app_couch_doc(
|
|
2574
|
+
app_id_reference,
|
|
2575
|
+
check_existing_file_ret.duplicates[0]._id
|
|
2576
|
+
);
|
|
2577
|
+
|
|
2578
|
+
break;
|
|
2579
|
+
}
|
|
2580
|
+
default:
|
|
2581
|
+
break;
|
|
2582
|
+
}
|
|
2583
|
+
|
|
2584
|
+
if (doc_ret.code < 0 && drive_type === "studio") {
|
|
2585
|
+
const ext = path.extname(file_name).toLowerCase();
|
|
2586
|
+
doc = {
|
|
2587
|
+
_id: file_name,
|
|
2588
|
+
docType: `${drive_type}_drive`,
|
|
2589
|
+
stat: 3,
|
|
2590
|
+
server_file_name: file_name,
|
|
2591
|
+
originalname: file_name,
|
|
2592
|
+
uid,
|
|
2593
|
+
date_created: Date.now(),
|
|
2594
|
+
ip: headers["cf-connecting-ip"],
|
|
2595
|
+
country: headers["cf-ipcountry"],
|
|
2596
|
+
file_ext: ext,
|
|
2597
|
+
is_archive: _conf.archive_drive_ext.includes(ext) ? true : false,
|
|
2598
|
+
drive_type,
|
|
2599
|
+
};
|
|
2600
|
+
|
|
2601
|
+
doc.app_id = await _common.get_project_app_id(app_id);
|
|
2602
|
+
doc.app_id_reference = await _common.get_project_app_id(app_id, true);
|
|
2603
|
+
}
|
|
2604
|
+
};
|