@xuda.io/drive_module 1.1.791 → 1.1.793

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 +28 -55
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -505,67 +505,31 @@ 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
- delete doc._id;
544
- delete doc._rev;
510
+ delete doc._id;
511
+ delete doc._rev;
545
512
 
546
- delete doc.docType;
547
- delete doc.stat;
548
- if (doc.bucket) {
549
- doc.regions = Object.entries(doc.bucket).length;
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
- delete doc.bucket;
553
- if (doc.uid) {
554
- let ret = await db_module.get_couch_doc("xuda_accounts", doc.uid);
555
- doc.account_info = ret.data.account_info;
556
- }
557
- if (req.drive_type === "workspace") {
558
- const app_id_master = await _common.get_project_app_id(app_id, true);
559
- const ret = await db_module.get_app_obj(app_id_master);
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
- if (ret.code < 0) {
562
- return ret;
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
- } else if (drive_type === "studio") {
568
- statsObj = fs.statSync(file_path);
531
+ const app_obj = ret.data;
532
+ doc.app_name = app_obj.app_name;
569
533
  }
570
534
 
571
535
  return {
@@ -2666,11 +2630,20 @@ const get_drive_doc = async function (
2666
2630
 
2667
2631
  case "workspace": {
2668
2632
  const app_id_reference = await _common.get_project_app_id(app_id);
2633
+
2669
2634
  doc_ret = await db_module.get_app_couch_doc(
2670
2635
  app_id_reference,
2671
2636
  check_existing_file_ret.duplicates[0]._id
2672
2637
  );
2673
2638
 
2639
+ if (
2640
+ doc_ret?.data?.type === "file" &&
2641
+ !file_path.includes(app_id) &&
2642
+ !file_path.includes(app_id_master)
2643
+ ) {
2644
+ throw new Error("file_path unauthorized");
2645
+ }
2646
+
2674
2647
  break;
2675
2648
  }
2676
2649
  default:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xuda.io/drive_module",
3
- "version": "1.1.791",
3
+ "version": "1.1.793",
4
4
  "description": "Xuda Drive Server Module",
5
5
  "main": "index.js",
6
6
  "dependencies": {