@xuda.io/drive_module 1.1.1467 → 1.1.1468
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.mjs +0 -99
- package/package.json +1 -1
package/index.mjs
CHANGED
|
@@ -482,104 +482,6 @@ const get_folder_files = async function (uid, app_id, drive_type, path) {
|
|
|
482
482
|
return [...(files_ret.data.children || []), ...(directory_ret.data.children || [])];
|
|
483
483
|
};
|
|
484
484
|
|
|
485
|
-
// export const delete_drive_files = async (req, job_id, headers) => {
|
|
486
|
-
// try {
|
|
487
|
-
// const { drive_type, app_id, files_arr, uid } = req;
|
|
488
|
-
// validate_drive_type(drive_type);
|
|
489
|
-
|
|
490
|
-
// if (!Array.isArray(files_arr)) {
|
|
491
|
-
// return {
|
|
492
|
-
// code: -400,
|
|
493
|
-
// data: 'error - files_arr must be Array',
|
|
494
|
-
// };
|
|
495
|
-
// }
|
|
496
|
-
|
|
497
|
-
// for await (const file of files_arr) {
|
|
498
|
-
// let doc = await get_drive_doc(file.type, drive_type, app_id, uid, file.file_path, headers);
|
|
499
|
-
|
|
500
|
-
// // if (doc.is_system) {
|
|
501
|
-
// // throw new Error(`${doc.type} protected`);
|
|
502
|
-
// // }
|
|
503
|
-
|
|
504
|
-
// if (doc.type === 'directory') {
|
|
505
|
-
// const files_in_directory = await get_folder_files(uid, app_id, drive_type, path.join(doc.file_path, doc.folder_name));
|
|
506
|
-
// if (files_in_directory?.length) {
|
|
507
|
-
// throw new Error(`Directory is not empty`);
|
|
508
|
-
// }
|
|
509
|
-
// }
|
|
510
|
-
|
|
511
|
-
// let save_ret;
|
|
512
|
-
// switch (drive_type) {
|
|
513
|
-
// case 'studio': {
|
|
514
|
-
// const app_id_reference = await _common.get_project_app_id(app_id);
|
|
515
|
-
// const target_dir = path.join(_conf[`studio_drive_path`], app_id_reference, file.file_path);
|
|
516
|
-
// console.log('target_dir', target_dir);
|
|
517
|
-
// rimraf.sync(target_dir);
|
|
518
|
-
|
|
519
|
-
// if (doc.type === 'file') {
|
|
520
|
-
// doc.ts = Date.now();
|
|
521
|
-
// doc.stat = 4;
|
|
522
|
-
// save_ret = await db_module.save_app_couch_doc(app_id_reference, doc);
|
|
523
|
-
// }
|
|
524
|
-
|
|
525
|
-
// misc_msa.rsync_drive_resources_to_remote_servers('studio', app_id_reference);
|
|
526
|
-
// break;
|
|
527
|
-
// }
|
|
528
|
-
|
|
529
|
-
// case 'workspace': {
|
|
530
|
-
// // const app_id_reference = await _common.get_project_app_id(app_id);
|
|
531
|
-
|
|
532
|
-
// if (doc.type === 'file') {
|
|
533
|
-
// try {
|
|
534
|
-
// if (doc.bucket) {
|
|
535
|
-
// await delete_file_from_bucket(doc.bucket);
|
|
536
|
-
// } else {
|
|
537
|
-
// const { data: app_obj } = await db_module.get_app_obj(app_id);
|
|
538
|
-
// if (app_obj?.app_type === 'datacenter') {
|
|
539
|
-
// const host = `root@${app_obj.app_hosting_server.ip}`;
|
|
540
|
-
// await _utils.run_ssh_script(`ssh ${host} "mv /var/xuda/workspace_drive/${doc.server_file_name} /tmp/;" `);
|
|
541
|
-
// } else if (app_obj?.is_deployment) {
|
|
542
|
-
// const { data: datacenter_obj } = await db_module.get_app_obj(app_obj.app_datacenter_id);
|
|
543
|
-
// const host = `root@${datacenter_obj.app_hosting_server.ip}`;
|
|
544
|
-
// await _utils.run_ssh_script(`ssh ${host} "mv /var/xuda/workspace_drive/${doc.server_file_name} /tmp/;" `);
|
|
545
|
-
// }
|
|
546
|
-
// }
|
|
547
|
-
// } catch (error) {}
|
|
548
|
-
// }
|
|
549
|
-
|
|
550
|
-
// doc.ts = Date.now();
|
|
551
|
-
// doc.stat = 4;
|
|
552
|
-
// save_ret = await save_drive_doc(drive_type, uid, app_id, doc);
|
|
553
|
-
|
|
554
|
-
// break;
|
|
555
|
-
// }
|
|
556
|
-
|
|
557
|
-
// case 'user': {
|
|
558
|
-
// if (doc.type === 'file') {
|
|
559
|
-
// try {
|
|
560
|
-
// await delete_file_from_bucket(doc.bucket);
|
|
561
|
-
// } catch (error) {}
|
|
562
|
-
// }
|
|
563
|
-
// doc.ts = Date.now();
|
|
564
|
-
// doc.stat = 4;
|
|
565
|
-
// save_ret = await save_drive_doc(drive_type, uid, app_id, doc);
|
|
566
|
-
|
|
567
|
-
// break;
|
|
568
|
-
// }
|
|
569
|
-
// default:
|
|
570
|
-
// break;
|
|
571
|
-
// }
|
|
572
|
-
// }
|
|
573
|
-
|
|
574
|
-
// return {
|
|
575
|
-
// code: 200,
|
|
576
|
-
// data: req.files_arr,
|
|
577
|
-
// };
|
|
578
|
-
// } catch (err) {
|
|
579
|
-
// return { code: -1, data: err.message };
|
|
580
|
-
// }
|
|
581
|
-
// };
|
|
582
|
-
|
|
583
485
|
export const delete_drive_files = async (req, job_id, headers) => {
|
|
584
486
|
let ret = [];
|
|
585
487
|
try {
|
|
@@ -1399,7 +1301,6 @@ export const check_drive_file = async (req, job_id, headers, file_obj) => {
|
|
|
1399
1301
|
type,
|
|
1400
1302
|
file_path: path.dirname(file_path),
|
|
1401
1303
|
stat: 3,
|
|
1402
|
-
// uid,
|
|
1403
1304
|
};
|
|
1404
1305
|
|
|
1405
1306
|
if (type === 'file') {
|