@xuda.io/drive_module 1.1.832 → 1.1.834

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 +42 -90
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -510,7 +510,14 @@ exports.get_drive_file_info = async function (req, job_id, headers) {
510
510
  try {
511
511
  const { type, drive_type, uid, app_id, file_path } = req;
512
512
 
513
- let doc = await get_drive_doc(drive_type, app_id, uid, file_path, headers);
513
+ let doc = await get_drive_doc(
514
+ type,
515
+ drive_type,
516
+ app_id,
517
+ uid,
518
+ file_path,
519
+ headers
520
+ );
514
521
 
515
522
  delete doc._id;
516
523
  delete doc._rev;
@@ -860,7 +867,14 @@ exports.update_drive_file = async function (req, job_id, headers, file_obj) {
860
867
  return { code: -4, data: "file data missing" };
861
868
  }
862
869
 
863
- let doc = await get_drive_doc(drive_type, app_id, uid, file_path, headers);
870
+ let doc = await get_drive_doc(
871
+ type,
872
+ drive_type,
873
+ app_id,
874
+ uid,
875
+ file_path,
876
+ headers
877
+ );
864
878
 
865
879
  var target_file = file_path;
866
880
  const master_id = await _common.get_project_app_id(app_id, true);
@@ -1102,7 +1116,14 @@ exports.rename_drive_file = async function (req, job_id, headers) {
1102
1116
  const { drive_type, app_id, file_name_to, file_path } = req;
1103
1117
  validate_drive_type(drive_type);
1104
1118
 
1105
- let doc = await get_drive_doc(drive_type, app_id, uid, file_path, headers);
1119
+ let doc = await get_drive_doc(
1120
+ "file",
1121
+ drive_type,
1122
+ app_id,
1123
+ uid,
1124
+ file_path,
1125
+ headers
1126
+ );
1106
1127
 
1107
1128
  if (drive_type === "studio") {
1108
1129
  await fs_module.rename(file_path, file_name_to);
@@ -1260,11 +1281,18 @@ exports.rename_drive_folder = async function (req) {
1260
1281
  };
1261
1282
  exports.update_drive_file_sharing_mode = async function (req, job_id, headers) {
1262
1283
  try {
1263
- const { drive_type, uid, app_id, file_path, is_public } = req;
1284
+ const { type, drive_type, uid, app_id, file_path, is_public } = req;
1264
1285
 
1265
1286
  validate_drive_type(drive_type);
1266
1287
 
1267
- let doc = await get_drive_doc(drive_type, app_id, uid, file_path, headers);
1288
+ let doc = await get_drive_doc(
1289
+ type,
1290
+ drive_type,
1291
+ app_id,
1292
+ uid,
1293
+ file_path,
1294
+ headers
1295
+ );
1268
1296
 
1269
1297
  doc.ts = Date.now();
1270
1298
  doc.public = is_public;
@@ -1401,7 +1429,14 @@ exports.extract_drive_file = async function (req, job_id, headers) {
1401
1429
  const app_id_master = await _common.get_project_app_id(app_id, true);
1402
1430
  const app_id_reference = await _common.get_project_app_id(app_id);
1403
1431
 
1404
- let doc = await get_drive_doc(drive_type, app_id, uid, file_path, headers);
1432
+ let doc = await get_drive_doc(
1433
+ "file",
1434
+ drive_type,
1435
+ app_id,
1436
+ uid,
1437
+ file_path,
1438
+ headers
1439
+ );
1405
1440
 
1406
1441
  const ext = path.extname(file_path).toLowerCase();
1407
1442
 
@@ -1858,91 +1893,7 @@ exports.check_drive_file = async function (req, job_id, headers, file_obj) {
1858
1893
  data: "ok",
1859
1894
  };
1860
1895
  };
1861
- // exports.check_drive_file = async function (req, job_id, headers, file_obj) {
1862
- // const { drive_type, app_id, uid, file_name, file_path } = req;
1863
- // var master_app_id;
1864
-
1865
- // if (["studio", "workspace"].includes(drive_type)) {
1866
- // master_app_id = await _common.get_project_app_id(app_id, true);
1867
- // }
1868
- // let doc = await get_drive_doc(drive_type, app_id, uid, file_path, headers);
1869
-
1870
- // switch (drive_type) {
1871
- // case "studio": {
1872
- // const target_dir = path.join(_conf[`studio_drive_path`], master_app_id);
1873
-
1874
- // target_file = path.join(
1875
- // file_path !== "/" ? file_path : target_dir,
1876
- // file_name
1877
- // );
1878
-
1879
- // if (await fs_module.file_exists(target_file)) {
1880
- // return {
1881
- // code: -764,
1882
- // data: "file exist",
1883
- // };
1884
- // }
1885
-
1886
- // break;
1887
- // }
1888
- // case "workspace": {
1889
- // const workspace_drive_res = await db_module.find_app_couch_query(
1890
- // master_app_id,
1891
- // {
1892
- // selector: {
1893
- // docType: "workspace_drive",
1894
- // originalname: file_name,
1895
- // file_path,
1896
- // stat: 3,
1897
- // },
1898
- // limit: 99,
1899
- // }
1900
- // );
1901
- // if (workspace_drive_res.docs.length) {
1902
- // return {
1903
- // code: -764,
1904
- // data: "file exist",
1905
- // duplicates: workspace_drive_res.docs,
1906
- // };
1907
- // }
1908
-
1909
- // break;
1910
- // }
1911
- // case "user": {
1912
- // const user_drive_res = await db_module.find_couch_query("xuda_drive", {
1913
- // selector: {
1914
- // docType: "user_drive",
1915
- // originalname: file_name,
1916
- // file_path,
1917
- // uid,
1918
- // stat: 3,
1919
- // },
1920
- // limit: 99,
1921
- // });
1922
- // if (user_drive_res.docs.length) {
1923
- // return {
1924
- // code: -764,
1925
- // data: "file exist",
1926
- // duplicates: user_drive_res.docs,
1927
- // };
1928
- // }
1929
1896
 
1930
- // break;
1931
- // }
1932
-
1933
- // default:
1934
- // return {
1935
- // code: -764,
1936
- // data: "invalid method",
1937
- // };
1938
- // break;
1939
- // }
1940
-
1941
- // return {
1942
- // code: 764,
1943
- // data: "ok",
1944
- // };
1945
- // };
1946
1897
  const ocr_drive_file = async function (doc) {
1947
1898
  const { drive_type, target_file } = doc;
1948
1899
  var doc_ret;
@@ -2654,6 +2605,7 @@ const get_drive_doc = async function (
2654
2605
  uid,
2655
2606
  drive_type,
2656
2607
  file_path,
2608
+ type,
2657
2609
  };
2658
2610
  const check_existing_file_ret = await module.exports.check_drive_file(
2659
2611
  check_req
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xuda.io/drive_module",
3
- "version": "1.1.832",
3
+ "version": "1.1.834",
4
4
  "description": "Xuda Drive Server Module",
5
5
  "main": "index.js",
6
6
  "dependencies": {