@xuda.io/drive_module 1.1.649 → 1.1.651
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 +103 -2
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -399,9 +399,10 @@ exports.get_drive_file_info = async function (req) {
|
|
|
399
399
|
doc_id,
|
|
400
400
|
doc = {};
|
|
401
401
|
|
|
402
|
+
const app_id_master = await _common.get_project_app_id(app_id, true);
|
|
403
|
+
|
|
402
404
|
switch (drive_type) {
|
|
403
405
|
case "studio": {
|
|
404
|
-
const app_id_master = await _common.get_project_app_id(app_id, true);
|
|
405
406
|
const target_dir = path.join(_conf[`studio_drive_path`], app_id_master);
|
|
406
407
|
doc_id = file_path.replace(target_dir, "");
|
|
407
408
|
doc_ret = await db_module.get_app_couch_doc(app_id_master, doc_id);
|
|
@@ -409,7 +410,11 @@ exports.get_drive_file_info = async function (req) {
|
|
|
409
410
|
}
|
|
410
411
|
|
|
411
412
|
case "workspace": {
|
|
412
|
-
if (
|
|
413
|
+
if (
|
|
414
|
+
type === "file" &&
|
|
415
|
+
!file_path.includes(app_id) &&
|
|
416
|
+
!file_path.includes(app_id_master)
|
|
417
|
+
) {
|
|
413
418
|
throw new Error("file_path unauthorized");
|
|
414
419
|
}
|
|
415
420
|
const app_id_reference = await _common.get_project_app_id(app_id);
|
|
@@ -2304,4 +2309,100 @@ const get_folder_docs = async function (dir, drive_type, app_id) {
|
|
|
2304
2309
|
return docs;
|
|
2305
2310
|
};
|
|
2306
2311
|
|
|
2312
|
+
exports.update_drive_file_tags = async function (req) {
|
|
2313
|
+
try {
|
|
2314
|
+
const { drive_type, uid, app_id, file_name_id } = req;
|
|
2315
|
+
validate_drive_type(drive_type);
|
|
2316
|
+
|
|
2317
|
+
let doc_ret;
|
|
2318
|
+
|
|
2319
|
+
switch (drive_type) {
|
|
2320
|
+
case "studio": {
|
|
2321
|
+
const app_id_master = await _common.get_project_app_id(app_id, true);
|
|
2322
|
+
doc_ret = await db_module.get_app_couch_doc(
|
|
2323
|
+
app_id_master,
|
|
2324
|
+
file_name_id
|
|
2325
|
+
);
|
|
2326
|
+
await fs_module.rename(file_name_id, file_name_to);
|
|
2327
|
+
if (doc_ret.code > -1) {
|
|
2328
|
+
doc_ret.data._delete = true;
|
|
2329
|
+
save_ret = await db_module.save_app_couch_doc(
|
|
2330
|
+
app_id_master,
|
|
2331
|
+
doc_ret.data
|
|
2332
|
+
);
|
|
2333
|
+
|
|
2334
|
+
doc_ret.data._id = file_name_to;
|
|
2335
|
+
delete doc_ret.data._rev;
|
|
2336
|
+
}
|
|
2337
|
+
misc_module.rsync_drive_resources_to_remote_servers(
|
|
2338
|
+
"studio",
|
|
2339
|
+
app_id_master
|
|
2340
|
+
);
|
|
2341
|
+
break;
|
|
2342
|
+
}
|
|
2343
|
+
case "workspace": {
|
|
2344
|
+
const app_id_reference = await _common.get_project_app_id(app_id);
|
|
2345
|
+
doc_ret = await db_module.get_app_couch_doc(
|
|
2346
|
+
app_id_reference,
|
|
2347
|
+
path.basename(file_name_id)
|
|
2348
|
+
);
|
|
2349
|
+
if (doc_ret.code < 0) {
|
|
2350
|
+
throw new Error(doc_ret.data);
|
|
2351
|
+
}
|
|
2352
|
+
|
|
2353
|
+
break;
|
|
2354
|
+
}
|
|
2355
|
+
|
|
2356
|
+
case "user":
|
|
2357
|
+
doc_ret = await db_module.get_couch_doc(
|
|
2358
|
+
"xuda_drive",
|
|
2359
|
+
path.basename(file_name_id)
|
|
2360
|
+
);
|
|
2361
|
+
if (doc_ret.code < 0) {
|
|
2362
|
+
throw new Error(doc_ret.data);
|
|
2363
|
+
}
|
|
2364
|
+
|
|
2365
|
+
break;
|
|
2366
|
+
|
|
2367
|
+
default:
|
|
2368
|
+
break;
|
|
2369
|
+
}
|
|
2370
|
+
|
|
2371
|
+
if (doc_ret.code > -1) {
|
|
2372
|
+
var doc = doc_ret.data;
|
|
2373
|
+
doc.date_modified = Date.now();
|
|
2374
|
+
doc.originalname = file_name_to;
|
|
2375
|
+
let save_ret;
|
|
2376
|
+
|
|
2377
|
+
switch (drive_type) {
|
|
2378
|
+
case "workspace":
|
|
2379
|
+
case "studio":
|
|
2380
|
+
const app_id_reference = await _common.get_project_app_id(app_id);
|
|
2381
|
+
save_ret = await db_module.save_app_couch_doc(app_id_reference, doc);
|
|
2382
|
+
break;
|
|
2383
|
+
|
|
2384
|
+
case "user":
|
|
2385
|
+
save_ret = await db_module.save_couch_doc("xuda_drive", doc);
|
|
2386
|
+
break;
|
|
2387
|
+
|
|
2388
|
+
default:
|
|
2389
|
+
break;
|
|
2390
|
+
}
|
|
2391
|
+
|
|
2392
|
+
if (save_ret.code < 0) {
|
|
2393
|
+
throw new Error(save_ret.data);
|
|
2394
|
+
}
|
|
2395
|
+
}
|
|
2396
|
+
return {
|
|
2397
|
+
code: 200,
|
|
2398
|
+
data: file_name_to,
|
|
2399
|
+
};
|
|
2400
|
+
} catch (err) {
|
|
2401
|
+
return {
|
|
2402
|
+
code: -200,
|
|
2403
|
+
data: err.message,
|
|
2404
|
+
};
|
|
2405
|
+
}
|
|
2406
|
+
};
|
|
2407
|
+
|
|
2307
2408
|
setTimeout(function () {}, 2000);
|