@xuda.io/drive_module 1.1.792 → 1.1.794
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 +21 -59
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -505,77 +505,39 @@ exports.get_drive_file_info = async function (req, job_id, headers) {
|
|
|
505
505
|
|
|
506
506
|
const app_id_master = await _common.get_project_app_id(app_id, true);
|
|
507
507
|
|
|
508
|
-
switch (drive_type) {
|
|
509
|
-
case "studio": {
|
|
510
|
-
const target_dir = path.join(_conf[`studio_drive_path`], app_id_master);
|
|
511
|
-
doc_id = file_path.replace(target_dir, "");
|
|
512
|
-
doc_ret = await db_module.get_app_couch_doc(app_id_master, doc_id);
|
|
513
|
-
break;
|
|
514
|
-
}
|
|
515
|
-
|
|
516
|
-
case "workspace": {
|
|
517
|
-
if (
|
|
518
|
-
type === "file" &&
|
|
519
|
-
!file_path.includes(app_id) &&
|
|
520
|
-
!file_path.includes(app_id_master)
|
|
521
|
-
) {
|
|
522
|
-
throw new Error("file_path unauthorized");
|
|
523
|
-
}
|
|
524
|
-
const app_id_reference = await _common.get_project_app_id(app_id);
|
|
525
|
-
doc_id = path.basename(file_path);
|
|
526
|
-
doc_ret = await db_module.get_app_couch_doc(app_id_reference, doc_id);
|
|
527
|
-
break;
|
|
528
|
-
}
|
|
529
|
-
|
|
530
|
-
case "user": {
|
|
531
|
-
doc_id = path.basename(file_path);
|
|
532
|
-
doc_ret = await db_module.get_couch_doc("xuda_drive", doc_id);
|
|
533
|
-
break;
|
|
534
|
-
}
|
|
535
|
-
default:
|
|
536
|
-
break;
|
|
537
|
-
}
|
|
538
|
-
|
|
539
508
|
var statsObj = {};
|
|
540
|
-
if (doc_ret.code > -1) {
|
|
541
|
-
doc = doc_ret.data;
|
|
542
509
|
|
|
543
|
-
|
|
544
|
-
|
|
510
|
+
delete doc._id;
|
|
511
|
+
delete doc._rev;
|
|
545
512
|
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
513
|
+
delete doc.docType;
|
|
514
|
+
delete doc.stat;
|
|
515
|
+
if (doc.bucket) {
|
|
516
|
+
doc.regions = Object.entries(doc.bucket).length;
|
|
517
|
+
}
|
|
551
518
|
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
519
|
+
delete doc.bucket;
|
|
520
|
+
if (doc.uid) {
|
|
521
|
+
let ret = await db_module.get_couch_doc("xuda_accounts", doc.uid);
|
|
522
|
+
doc.account_info = ret.data.account_info;
|
|
523
|
+
}
|
|
524
|
+
if (req.drive_type === "workspace") {
|
|
525
|
+
const app_id_master = await _common.get_project_app_id(app_id, true);
|
|
526
|
+
const ret = await db_module.get_app_obj(app_id_master);
|
|
560
527
|
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
}
|
|
564
|
-
const app_obj = ret.data;
|
|
565
|
-
doc.app_name = app_obj.app_name;
|
|
528
|
+
if (ret.code < 0) {
|
|
529
|
+
return ret;
|
|
566
530
|
}
|
|
567
|
-
|
|
568
|
-
|
|
531
|
+
const app_obj = ret.data;
|
|
532
|
+
doc.app_name = app_obj.app_name;
|
|
569
533
|
}
|
|
570
534
|
|
|
571
535
|
return {
|
|
572
536
|
code: 200,
|
|
573
537
|
data: {
|
|
574
538
|
name: doc_ret.code < 0 ? file_name : doc.originalname,
|
|
575
|
-
cy_data:
|
|
576
|
-
|
|
577
|
-
? { date_created: new Date(statsObj.birthtime).valueOf() }
|
|
578
|
-
: doc,
|
|
539
|
+
cy_data: doc,
|
|
540
|
+
|
|
579
541
|
exif_data: doc.exif_data,
|
|
580
542
|
},
|
|
581
543
|
};
|