@xuda.io/drive_module 1.1.800 → 1.1.802
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 +140 -107
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -1107,31 +1107,29 @@ exports.rename_drive_file = async function (req, job_id, headers) {
|
|
|
1107
1107
|
delete doc._rev;
|
|
1108
1108
|
}
|
|
1109
1109
|
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
doc.originalname = file_name_to;
|
|
1114
|
-
let save_ret;
|
|
1110
|
+
doc.date_modified = Date.now();
|
|
1111
|
+
doc.originalname = file_name_to;
|
|
1112
|
+
let save_ret;
|
|
1115
1113
|
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1114
|
+
switch (drive_type) {
|
|
1115
|
+
case "workspace":
|
|
1116
|
+
case "studio":
|
|
1117
|
+
const app_id_reference = await _common.get_project_app_id(app_id);
|
|
1118
|
+
save_ret = await db_module.save_app_couch_doc(app_id_reference, doc);
|
|
1119
|
+
break;
|
|
1122
1120
|
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1121
|
+
case "user":
|
|
1122
|
+
save_ret = await db_module.save_couch_doc("xuda_drive", doc);
|
|
1123
|
+
break;
|
|
1126
1124
|
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1125
|
+
default:
|
|
1126
|
+
break;
|
|
1127
|
+
}
|
|
1130
1128
|
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
}
|
|
1129
|
+
if (save_ret.code < 0) {
|
|
1130
|
+
throw new Error(save_ret.data);
|
|
1134
1131
|
}
|
|
1132
|
+
|
|
1135
1133
|
return {
|
|
1136
1134
|
code: 200,
|
|
1137
1135
|
data: file_name_to,
|
|
@@ -1259,94 +1257,9 @@ exports.update_drive_file_sharing_mode = async function (req, job_id, headers) {
|
|
|
1259
1257
|
|
|
1260
1258
|
validate_drive_type(drive_type);
|
|
1261
1259
|
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
let check_req = {
|
|
1265
|
-
app_id,
|
|
1266
|
-
uid,
|
|
1267
|
-
drive_type,
|
|
1268
|
-
file_path,
|
|
1269
|
-
};
|
|
1270
|
-
const check_existing_file_ret = await module.exports.check_drive_file(
|
|
1271
|
-
check_req
|
|
1272
|
-
);
|
|
1273
|
-
|
|
1274
|
-
let doc_ret;
|
|
1275
|
-
|
|
1276
|
-
switch (drive_type) {
|
|
1277
|
-
case "studio": {
|
|
1278
|
-
const app_id_reference = await _common.get_project_app_id(app_id);
|
|
1279
|
-
doc_ret = await db_module.get_app_couch_doc(
|
|
1280
|
-
app_id_reference,
|
|
1281
|
-
file_path
|
|
1282
|
-
);
|
|
1283
|
-
break;
|
|
1284
|
-
}
|
|
1285
|
-
case "user":
|
|
1286
|
-
doc_ret = await db_module.get_couch_doc(
|
|
1287
|
-
"xuda_drive",
|
|
1288
|
-
check_existing_file_ret.duplicates[0]._id
|
|
1289
|
-
);
|
|
1290
|
-
break;
|
|
1291
|
-
|
|
1292
|
-
case "workspace": {
|
|
1293
|
-
const app_id_reference = await _common.get_project_app_id(app_id);
|
|
1294
|
-
doc_ret = await db_module.get_app_couch_doc(
|
|
1295
|
-
app_id_reference,
|
|
1296
|
-
check_existing_file_ret.duplicates[0]._id
|
|
1297
|
-
);
|
|
1298
|
-
|
|
1299
|
-
break;
|
|
1300
|
-
}
|
|
1301
|
-
default:
|
|
1302
|
-
break;
|
|
1303
|
-
}
|
|
1304
|
-
|
|
1305
|
-
var doc = doc_ret.data;
|
|
1306
|
-
|
|
1307
|
-
if (doc_ret.code < 0 && drive_type === "studio") {
|
|
1308
|
-
const ext = path.extname(file_name).toLowerCase();
|
|
1309
|
-
doc = {
|
|
1310
|
-
_id: file_name,
|
|
1311
|
-
docType: `${drive_type}_drive`,
|
|
1312
|
-
stat: 3,
|
|
1313
|
-
server_file_name: file_name,
|
|
1314
|
-
originalname: file_name,
|
|
1315
|
-
uid,
|
|
1316
|
-
date_created: Date.now(),
|
|
1317
|
-
ip: headers["cf-connecting-ip"],
|
|
1318
|
-
country: headers["cf-ipcountry"],
|
|
1319
|
-
file_ext: ext,
|
|
1320
|
-
is_archive: _conf.archive_drive_ext.includes(ext) ? true : false,
|
|
1321
|
-
drive_type,
|
|
1322
|
-
};
|
|
1323
|
-
|
|
1324
|
-
// if (drive_type === "studio" || drive_type === "workspace") {
|
|
1325
|
-
doc.app_id = await _common.get_project_app_id(app_id);
|
|
1326
|
-
doc.app_id_reference = await _common.get_project_app_id(app_id, true);
|
|
1327
|
-
// }
|
|
1328
|
-
|
|
1329
|
-
// let save_ret;
|
|
1330
|
-
|
|
1331
|
-
// const app_id_reference = await _common.get_project_app_id(app_id);
|
|
1332
|
-
// save_ret = await db_module.save_app_couch_doc(app_id_reference, doc);
|
|
1333
|
-
|
|
1334
|
-
// switch (drive_type) {
|
|
1335
|
-
// case "workspace":
|
|
1336
|
-
// case "studio":
|
|
1337
|
-
// const app_id_reference = await _common.get_project_app_id(app_id);
|
|
1338
|
-
// save_ret = await db_module.save_app_couch_doc(app_id_reference, doc);
|
|
1339
|
-
// break;
|
|
1340
|
-
|
|
1341
|
-
// case "user":
|
|
1342
|
-
// save_ret = await db_module.save_couch_doc("xuda_drive", doc);
|
|
1343
|
-
// break;
|
|
1260
|
+
let doc = await get_drive_doc(drive_type, app_id, uid, file_path, headers);
|
|
1344
1261
|
|
|
1345
|
-
|
|
1346
|
-
// break;
|
|
1347
|
-
// }
|
|
1348
|
-
// return save_ret;
|
|
1349
|
-
}
|
|
1262
|
+
const file_name = path.basename(file_path);
|
|
1350
1263
|
|
|
1351
1264
|
doc.ts = Date.now();
|
|
1352
1265
|
doc.public = is_public;
|
|
@@ -1373,6 +1286,126 @@ exports.update_drive_file_sharing_mode = async function (req, job_id, headers) {
|
|
|
1373
1286
|
return err.message;
|
|
1374
1287
|
}
|
|
1375
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
|
+
// };
|
|
1376
1409
|
|
|
1377
1410
|
exports.extract_drive_file = async function (req, job_id, headers) {
|
|
1378
1411
|
const { app_id, file_path, file_id, uid } = req;
|