@xuda.io/drive_module 1.1.801 → 1.1.803

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 +130 -87
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -1257,94 +1257,9 @@ exports.update_drive_file_sharing_mode = async function (req, job_id, headers) {
1257
1257
 
1258
1258
  validate_drive_type(drive_type);
1259
1259
 
1260
- const file_name = path.basename(file_path);
1261
-
1262
- let check_req = {
1263
- app_id,
1264
- uid,
1265
- drive_type,
1266
- file_path,
1267
- };
1268
- const check_existing_file_ret = await module.exports.check_drive_file(
1269
- check_req
1270
- );
1271
-
1272
- let doc_ret;
1273
-
1274
- switch (drive_type) {
1275
- case "studio": {
1276
- const app_id_reference = await _common.get_project_app_id(app_id);
1277
- doc_ret = await db_module.get_app_couch_doc(
1278
- app_id_reference,
1279
- file_path
1280
- );
1281
- break;
1282
- }
1283
- case "user":
1284
- doc_ret = await db_module.get_couch_doc(
1285
- "xuda_drive",
1286
- check_existing_file_ret.duplicates[0]._id
1287
- );
1288
- break;
1289
-
1290
- case "workspace": {
1291
- const app_id_reference = await _common.get_project_app_id(app_id);
1292
- doc_ret = await db_module.get_app_couch_doc(
1293
- app_id_reference,
1294
- check_existing_file_ret.duplicates[0]._id
1295
- );
1296
-
1297
- break;
1298
- }
1299
- default:
1300
- break;
1301
- }
1302
-
1303
- var doc = doc_ret.data;
1304
-
1305
- if (doc_ret.code < 0 && drive_type === "studio") {
1306
- const ext = path.extname(file_name).toLowerCase();
1307
- doc = {
1308
- _id: file_name,
1309
- docType: `${drive_type}_drive`,
1310
- stat: 3,
1311
- server_file_name: file_name,
1312
- originalname: file_name,
1313
- uid,
1314
- date_created: Date.now(),
1315
- ip: headers["cf-connecting-ip"],
1316
- country: headers["cf-ipcountry"],
1317
- file_ext: ext,
1318
- is_archive: _conf.archive_drive_ext.includes(ext) ? true : false,
1319
- drive_type,
1320
- };
1321
-
1322
- // if (drive_type === "studio" || drive_type === "workspace") {
1323
- doc.app_id = await _common.get_project_app_id(app_id);
1324
- doc.app_id_reference = await _common.get_project_app_id(app_id, true);
1325
- // }
1326
-
1327
- // let save_ret;
1328
-
1329
- // const app_id_reference = await _common.get_project_app_id(app_id);
1330
- // save_ret = await db_module.save_app_couch_doc(app_id_reference, doc);
1331
-
1332
- // switch (drive_type) {
1333
- // case "workspace":
1334
- // case "studio":
1335
- // const app_id_reference = await _common.get_project_app_id(app_id);
1336
- // save_ret = await db_module.save_app_couch_doc(app_id_reference, doc);
1337
- // break;
1338
-
1339
- // case "user":
1340
- // save_ret = await db_module.save_couch_doc("xuda_drive", doc);
1341
- // break;
1260
+ let doc = await get_drive_doc(drive_type, app_id, uid, file_path, headers);
1342
1261
 
1343
- // default:
1344
- // break;
1345
- // }
1346
- // return save_ret;
1347
- }
1262
+ const file_name = path.basename(file_path);
1348
1263
 
1349
1264
  doc.ts = Date.now();
1350
1265
  doc.public = is_public;
@@ -1371,6 +1286,126 @@ exports.update_drive_file_sharing_mode = async function (req, job_id, headers) {
1371
1286
  return err.message;
1372
1287
  }
1373
1288
  };
1289
+ // exports.update_drive_file_sharing_mode = async function (req, job_id, headers) {
1290
+ // try {
1291
+ // const { drive_type, uid, app_id, file_path, is_public } = req;
1292
+
1293
+ // validate_drive_type(drive_type);
1294
+
1295
+ // const file_name = path.basename(file_path);
1296
+
1297
+ // let check_req = {
1298
+ // app_id,
1299
+ // uid,
1300
+ // drive_type,
1301
+ // file_path,
1302
+ // };
1303
+ // const check_existing_file_ret = await module.exports.check_drive_file(
1304
+ // check_req
1305
+ // );
1306
+
1307
+ // let doc_ret;
1308
+
1309
+ // switch (drive_type) {
1310
+ // case "studio": {
1311
+ // const app_id_reference = await _common.get_project_app_id(app_id);
1312
+ // doc_ret = await db_module.get_app_couch_doc(
1313
+ // app_id_reference,
1314
+ // file_path
1315
+ // );
1316
+ // break;
1317
+ // }
1318
+ // case "user":
1319
+ // doc_ret = await db_module.get_couch_doc(
1320
+ // "xuda_drive",
1321
+ // check_existing_file_ret.duplicates[0]._id
1322
+ // );
1323
+ // break;
1324
+
1325
+ // case "workspace": {
1326
+ // const app_id_reference = await _common.get_project_app_id(app_id);
1327
+ // doc_ret = await db_module.get_app_couch_doc(
1328
+ // app_id_reference,
1329
+ // check_existing_file_ret.duplicates[0]._id
1330
+ // );
1331
+
1332
+ // break;
1333
+ // }
1334
+ // default:
1335
+ // break;
1336
+ // }
1337
+
1338
+ // var doc = doc_ret.data;
1339
+
1340
+ // if (doc_ret.code < 0 && drive_type === "studio") {
1341
+ // const ext = path.extname(file_name).toLowerCase();
1342
+ // doc = {
1343
+ // _id: file_name,
1344
+ // docType: `${drive_type}_drive`,
1345
+ // stat: 3,
1346
+ // server_file_name: file_name,
1347
+ // originalname: file_name,
1348
+ // uid,
1349
+ // date_created: Date.now(),
1350
+ // ip: headers["cf-connecting-ip"],
1351
+ // country: headers["cf-ipcountry"],
1352
+ // file_ext: ext,
1353
+ // is_archive: _conf.archive_drive_ext.includes(ext) ? true : false,
1354
+ // drive_type,
1355
+ // };
1356
+
1357
+ // // if (drive_type === "studio" || drive_type === "workspace") {
1358
+ // doc.app_id = await _common.get_project_app_id(app_id);
1359
+ // doc.app_id_reference = await _common.get_project_app_id(app_id, true);
1360
+ // // }
1361
+
1362
+ // // let save_ret;
1363
+
1364
+ // // const app_id_reference = await _common.get_project_app_id(app_id);
1365
+ // // save_ret = await db_module.save_app_couch_doc(app_id_reference, doc);
1366
+
1367
+ // // switch (drive_type) {
1368
+ // // case "workspace":
1369
+ // // case "studio":
1370
+ // // const app_id_reference = await _common.get_project_app_id(app_id);
1371
+ // // save_ret = await db_module.save_app_couch_doc(app_id_reference, doc);
1372
+ // // break;
1373
+
1374
+ // // case "user":
1375
+ // // save_ret = await db_module.save_couch_doc("xuda_drive", doc);
1376
+ // // break;
1377
+
1378
+ // // default:
1379
+ // // break;
1380
+ // // }
1381
+ // // return save_ret;
1382
+ // }
1383
+
1384
+ // doc.ts = Date.now();
1385
+ // doc.public = is_public;
1386
+
1387
+ // let save_ret;
1388
+
1389
+ // switch (drive_type) {
1390
+ // case "workspace":
1391
+ // case "studio":
1392
+ // const app_id_reference = await _common.get_project_app_id(app_id);
1393
+ // save_ret = await db_module.save_app_couch_doc(app_id_reference, doc);
1394
+ // break;
1395
+
1396
+ // case "user":
1397
+ // save_ret = await db_module.save_couch_doc("xuda_drive", doc);
1398
+ // break;
1399
+
1400
+ // default:
1401
+ // break;
1402
+ // }
1403
+
1404
+ // return save_ret;
1405
+ // } catch (err) {
1406
+ // return err.message;
1407
+ // }
1408
+ // };
1374
1409
 
1375
1410
  exports.extract_drive_file = async function (req, job_id, headers) {
1376
1411
  const { app_id, file_path, file_id, uid } = req;
@@ -2741,3 +2776,11 @@ const get_drive_doc = async function (
2741
2776
 
2742
2777
  return doc;
2743
2778
  };
2779
+
2780
+ const save_drive_doc = async function (
2781
+ drive_type,
2782
+ app_id,
2783
+ uid,
2784
+ file_path,
2785
+ headers
2786
+ ) {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xuda.io/drive_module",
3
- "version": "1.1.801",
3
+ "version": "1.1.803",
4
4
  "description": "Xuda Drive Server Module",
5
5
  "main": "index.js",
6
6
  "dependencies": {