@xuda.io/drive_module 1.1.1489 → 1.1.1491
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 +424 -5
- package/index.mjs.premerge.bak +3514 -0
- package/index_ms.mjs +88 -0
- package/index_msa.mjs +88 -0
- package/package.json +1 -1
package/index.mjs
CHANGED
|
@@ -19,11 +19,7 @@ import { Upload } from '@aws-sdk/lib-storage';
|
|
|
19
19
|
|
|
20
20
|
console.log('Drive Module loaded...');
|
|
21
21
|
|
|
22
|
-
global._conf = (
|
|
23
|
-
await import(path.join(process.env.XUDA_HOME, process.env.XUDA_CONFIG), {
|
|
24
|
-
with: { type: 'json' },
|
|
25
|
-
})
|
|
26
|
-
).default;
|
|
22
|
+
global._conf = (await import(path.join(process.env.XUDA_HOME, "common", "load_conf.mjs"))).loadConf();
|
|
27
23
|
|
|
28
24
|
const _common = await import(path.join(process.env.XUDA_HOME, 'common', 'xuda_node_common.mjs'));
|
|
29
25
|
const _utils = await import(path.join(process.env.XUDA_HOME, 'common', 'xuda-cpi-utils.mjs'));
|
|
@@ -102,8 +98,12 @@ export const get_drive_files = async (req) => {
|
|
|
102
98
|
|
|
103
99
|
// The Starred view is flat — bookmarked items across ALL folders — so it
|
|
104
100
|
// ignores the folder path; the normal listing scopes to the current folder.
|
|
101
|
+
// `recent` (the Recent view) and `global` (the ⌘K drive search) are flat
|
|
102
|
+
// the same way — cross-folder, no path scope.
|
|
105
103
|
if (req.starred) {
|
|
106
104
|
opt.selector.starred = true;
|
|
105
|
+
} else if (req.recent || req.global) {
|
|
106
|
+
// flat cross-folder listing
|
|
107
107
|
} else if (file_path) {
|
|
108
108
|
opt.selector.file_path = file_path;
|
|
109
109
|
}
|
|
@@ -990,6 +990,351 @@ export const rename_drive_folder = async (req) => {
|
|
|
990
990
|
}
|
|
991
991
|
};
|
|
992
992
|
|
|
993
|
+
// Move files/folders into another folder within the same drive. The user +
|
|
994
|
+
// workspace drives store their hierarchy purely in CouchDB (file docs carry
|
|
995
|
+
// file_path = parent dir; folder docs file_path = parent dir + folder_name;
|
|
996
|
+
// the stored bytes are keyed by _id/bucket) — so a move is a metadata rewrite
|
|
997
|
+
// with zero storage I/O. Folders move their ENTIRE subtree
|
|
998
|
+
// (collect_folder_descendants + parent-path prefix rewrite). The studio drive
|
|
999
|
+
// is filesystem-keyed (doc _id = fs path) and is not supported here yet.
|
|
1000
|
+
// req: { drive_type, app_id, uid, files_arr: [{ type, file_path }], dest_path }
|
|
1001
|
+
export const move_drive_files = async (req, job_id, headers) => {
|
|
1002
|
+
try {
|
|
1003
|
+
const { drive_type, app_id, uid, files_arr, dest_path } = req;
|
|
1004
|
+
validate_drive_type(drive_type);
|
|
1005
|
+
|
|
1006
|
+
if (drive_type === 'studio') {
|
|
1007
|
+
throw new Error('Moving items in the studio drive is not supported yet');
|
|
1008
|
+
}
|
|
1009
|
+
if (!Array.isArray(files_arr) || !files_arr.length) {
|
|
1010
|
+
return { code: -400, data: 'error - files_arr must be a non-empty Array' };
|
|
1011
|
+
}
|
|
1012
|
+
if (typeof dest_path !== 'string' || !dest_path.startsWith('/')) {
|
|
1013
|
+
return { code: -400, data: 'error - dest_path must be an absolute drive path' };
|
|
1014
|
+
}
|
|
1015
|
+
|
|
1016
|
+
// Destination must be an existing folder (root always exists) — throws when missing.
|
|
1017
|
+
if (dest_path !== '/') {
|
|
1018
|
+
await get_drive_doc('directory', drive_type, app_id, uid, dest_path, headers);
|
|
1019
|
+
}
|
|
1020
|
+
|
|
1021
|
+
// Existing names at the destination — refuse to silently overwrite.
|
|
1022
|
+
const dest_children = await get_folder_files(uid, app_id, drive_type, dest_path);
|
|
1023
|
+
const dest_names = new Set((dest_children || []).map((c) => c.name));
|
|
1024
|
+
|
|
1025
|
+
const conflicts = [];
|
|
1026
|
+
const moving = [];
|
|
1027
|
+
for (const item of files_arr) {
|
|
1028
|
+
if (!item || !item.file_path) continue;
|
|
1029
|
+
const item_name = path.basename(item.file_path);
|
|
1030
|
+
// Already in the destination — a no-op, skip silently.
|
|
1031
|
+
if (path.dirname(item.file_path) === dest_path) continue;
|
|
1032
|
+
// A folder can't be moved into itself or its own subtree.
|
|
1033
|
+
if (item.type === 'directory' && (dest_path === item.file_path || dest_path.startsWith(item.file_path + '/'))) {
|
|
1034
|
+
throw new Error(`Cannot move "${item_name}" into itself`);
|
|
1035
|
+
}
|
|
1036
|
+
if (dest_names.has(item_name)) {
|
|
1037
|
+
conflicts.push(item_name);
|
|
1038
|
+
continue;
|
|
1039
|
+
}
|
|
1040
|
+
moving.push(item);
|
|
1041
|
+
}
|
|
1042
|
+
if (conflicts.length) {
|
|
1043
|
+
return { code: -764, data: { error: 'name_conflict', conflicts } };
|
|
1044
|
+
}
|
|
1045
|
+
if (!moving.length) {
|
|
1046
|
+
return { code: 200, data: { moved: 0 } };
|
|
1047
|
+
}
|
|
1048
|
+
|
|
1049
|
+
const docs = [];
|
|
1050
|
+
for (const item of moving) {
|
|
1051
|
+
const doc = await get_drive_doc(item.type, drive_type, app_id, uid, item.file_path, headers);
|
|
1052
|
+
if (item.type === 'directory') {
|
|
1053
|
+
const old_full = path.join(doc.file_path, doc.folder_name);
|
|
1054
|
+
const new_full = path.join(dest_path, doc.folder_name);
|
|
1055
|
+
// Rewrite every descendant's parent-path prefix old_full → new_full.
|
|
1056
|
+
// Collected BEFORE the bulk save, so the queries still see old paths.
|
|
1057
|
+
const descendants = await collect_folder_descendants(uid, app_id, drive_type, old_full);
|
|
1058
|
+
for (const entry of descendants) {
|
|
1059
|
+
try {
|
|
1060
|
+
const child = await get_drive_doc(entry.type, drive_type, app_id, uid, entry.file_path, headers);
|
|
1061
|
+
if (child.file_path === old_full || child.file_path.startsWith(old_full + '/')) {
|
|
1062
|
+
child.file_path = new_full + child.file_path.slice(old_full.length);
|
|
1063
|
+
child.date_modified = Date.now();
|
|
1064
|
+
docs.push(child);
|
|
1065
|
+
}
|
|
1066
|
+
} catch (error) {
|
|
1067
|
+
// Skip unreadable descendants; the rest of the subtree still moves.
|
|
1068
|
+
}
|
|
1069
|
+
}
|
|
1070
|
+
}
|
|
1071
|
+
doc.file_path = dest_path;
|
|
1072
|
+
doc.date_modified = Date.now();
|
|
1073
|
+
docs.push(doc);
|
|
1074
|
+
}
|
|
1075
|
+
|
|
1076
|
+
let app_id_save;
|
|
1077
|
+
switch (drive_type) {
|
|
1078
|
+
case 'workspace':
|
|
1079
|
+
app_id_save = await _common.get_project_app_id(app_id);
|
|
1080
|
+
break;
|
|
1081
|
+
case 'user':
|
|
1082
|
+
app_id_save = await get_account_default_project_id(uid);
|
|
1083
|
+
break;
|
|
1084
|
+
default:
|
|
1085
|
+
break;
|
|
1086
|
+
}
|
|
1087
|
+
const save_ret = await db_module.sava_app_couch_bulk_docs(app_id_save, docs);
|
|
1088
|
+
if (save_ret.code < 0) {
|
|
1089
|
+
throw new Error(save_ret.data);
|
|
1090
|
+
}
|
|
1091
|
+
|
|
1092
|
+
return { code: 200, data: { moved: moving.length, docs: docs.length } };
|
|
1093
|
+
} catch (err) {
|
|
1094
|
+
return { code: -200, data: err.message };
|
|
1095
|
+
}
|
|
1096
|
+
};
|
|
1097
|
+
|
|
1098
|
+
// ─── Trash (user + workspace drives) ─────────────────────────────────────────
|
|
1099
|
+
// Soft-delete with restore. Unlike delete_drive_files (stat=4 + storage purge),
|
|
1100
|
+
// trashing only marks docs: stat=4, deleted_ts, trash_root = the trashed item's
|
|
1101
|
+
// full path (every doc in a trashed folder subtree carries the SAME trash_root,
|
|
1102
|
+
// so restore/purge can address the whole batch), is_trash_root on the top doc
|
|
1103
|
+
// (what the Trash view lists). Bytes stay in the bucket until purge. The studio
|
|
1104
|
+
// drive is filesystem-backed (files would keep being served from disk) — not
|
|
1105
|
+
// supported; the UI keeps hard-delete there.
|
|
1106
|
+
|
|
1107
|
+
const _trash_app_id = async (drive_type, app_id, uid) => {
|
|
1108
|
+
if (drive_type === 'workspace') return await _common.get_project_app_id(app_id);
|
|
1109
|
+
return await get_account_default_project_id(uid);
|
|
1110
|
+
};
|
|
1111
|
+
|
|
1112
|
+
const _validate_trash_drive = (drive_type) => {
|
|
1113
|
+
validate_drive_type(drive_type);
|
|
1114
|
+
if (drive_type === 'studio') {
|
|
1115
|
+
throw new Error('Trash is not supported for the studio drive');
|
|
1116
|
+
}
|
|
1117
|
+
};
|
|
1118
|
+
|
|
1119
|
+
// req: { drive_type, app_id, uid, files_arr: [{ type, file_path }] }
|
|
1120
|
+
export const trash_drive_files = async (req, job_id, headers) => {
|
|
1121
|
+
try {
|
|
1122
|
+
const { drive_type, app_id, uid, files_arr } = req;
|
|
1123
|
+
_validate_trash_drive(drive_type);
|
|
1124
|
+
if (!Array.isArray(files_arr) || !files_arr.length) {
|
|
1125
|
+
return { code: -400, data: 'error - files_arr must be a non-empty Array' };
|
|
1126
|
+
}
|
|
1127
|
+
|
|
1128
|
+
const now = Date.now();
|
|
1129
|
+
const docs = [];
|
|
1130
|
+
for (const item of files_arr) {
|
|
1131
|
+
if (!item || !item.file_path) continue;
|
|
1132
|
+
const doc = await get_drive_doc(item.type, drive_type, app_id, uid, item.file_path, headers);
|
|
1133
|
+
const root_path = item.type === 'directory' ? path.join(doc.file_path, doc.folder_name) : path.join(doc.file_path, doc.originalname);
|
|
1134
|
+
if (item.type === 'directory') {
|
|
1135
|
+
const descendants = await collect_folder_descendants(uid, app_id, drive_type, root_path);
|
|
1136
|
+
for (const entry of descendants) {
|
|
1137
|
+
try {
|
|
1138
|
+
const child = await get_drive_doc(entry.type, drive_type, app_id, uid, entry.file_path, headers);
|
|
1139
|
+
child.stat = 4;
|
|
1140
|
+
child.deleted_ts = now;
|
|
1141
|
+
child.trash_root = root_path;
|
|
1142
|
+
docs.push(child);
|
|
1143
|
+
} catch (error) {
|
|
1144
|
+
// Unreadable descendant — the rest of the subtree still trashes.
|
|
1145
|
+
}
|
|
1146
|
+
}
|
|
1147
|
+
}
|
|
1148
|
+
doc.stat = 4;
|
|
1149
|
+
doc.deleted_ts = now;
|
|
1150
|
+
doc.trash_root = root_path;
|
|
1151
|
+
doc.is_trash_root = true;
|
|
1152
|
+
docs.push(doc);
|
|
1153
|
+
}
|
|
1154
|
+
|
|
1155
|
+
const app_id_save = await _trash_app_id(drive_type, app_id, uid);
|
|
1156
|
+
const save_ret = await db_module.sava_app_couch_bulk_docs(app_id_save, docs);
|
|
1157
|
+
if (save_ret.code < 0) throw new Error(save_ret.data);
|
|
1158
|
+
return { code: 200, data: { trashed: docs.length } };
|
|
1159
|
+
} catch (err) {
|
|
1160
|
+
return { code: -200, data: err.message };
|
|
1161
|
+
}
|
|
1162
|
+
};
|
|
1163
|
+
|
|
1164
|
+
// Lists trash ROOTS (the items the user actually deleted, not every subtree doc).
|
|
1165
|
+
export const get_trashed_files = async (req) => {
|
|
1166
|
+
try {
|
|
1167
|
+
const { drive_type, app_id, uid } = req;
|
|
1168
|
+
_validate_trash_drive(drive_type);
|
|
1169
|
+
const app_id_q = await _trash_app_id(drive_type, app_id, uid);
|
|
1170
|
+
const ret = await db_module.find_app_couch_query(app_id_q, {
|
|
1171
|
+
selector: { docType: `${drive_type}_drive`, stat: 4, is_trash_root: true },
|
|
1172
|
+
limit: 500,
|
|
1173
|
+
});
|
|
1174
|
+
const docs = ret?.data?.docs || ret?.docs || [];
|
|
1175
|
+
const children = docs
|
|
1176
|
+
.map((d) => ({
|
|
1177
|
+
name: d.type === 'directory' ? d.folder_name : d.originalname,
|
|
1178
|
+
type: d.type,
|
|
1179
|
+
// Trash rows are addressed by their trash_root batch key.
|
|
1180
|
+
file_path: d.trash_root,
|
|
1181
|
+
trash_root: d.trash_root,
|
|
1182
|
+
orig_path: d.file_path,
|
|
1183
|
+
deleted_ts: d.deleted_ts,
|
|
1184
|
+
date_created: d.date_created,
|
|
1185
|
+
size: d.size ? (d.size < 1048576 ? (d.size / 1024).toFixed(1) + ' KB' : (d.size / 1048576).toFixed(1) + ' MB') : '',
|
|
1186
|
+
sizeInBytes: d.size || 0,
|
|
1187
|
+
tags: d.tags || [],
|
|
1188
|
+
extension: d?.file_ext?.substr(1),
|
|
1189
|
+
is_trashed: true,
|
|
1190
|
+
}))
|
|
1191
|
+
.sort((a, b) => (b.deleted_ts || 0) - (a.deleted_ts || 0));
|
|
1192
|
+
return { code: 200, data: { file_path: '/', name: 'Trash', children } };
|
|
1193
|
+
} catch (err) {
|
|
1194
|
+
return { code: -200, data: err.message };
|
|
1195
|
+
}
|
|
1196
|
+
};
|
|
1197
|
+
|
|
1198
|
+
// req: { drive_type, app_id, uid, trash_roots: [paths] } — restores each batch.
|
|
1199
|
+
export const restore_trashed_files = async (req) => {
|
|
1200
|
+
try {
|
|
1201
|
+
const { drive_type, app_id, uid, trash_roots } = req;
|
|
1202
|
+
_validate_trash_drive(drive_type);
|
|
1203
|
+
if (!Array.isArray(trash_roots) || !trash_roots.length) {
|
|
1204
|
+
return { code: -400, data: 'error - trash_roots must be a non-empty Array' };
|
|
1205
|
+
}
|
|
1206
|
+
const app_id_q = await _trash_app_id(drive_type, app_id, uid);
|
|
1207
|
+
const ret = await db_module.find_app_couch_query(app_id_q, {
|
|
1208
|
+
selector: { docType: `${drive_type}_drive`, stat: 4, trash_root: { $in: trash_roots } },
|
|
1209
|
+
limit: 10000,
|
|
1210
|
+
});
|
|
1211
|
+
const docs = ret?.data?.docs || ret?.docs || [];
|
|
1212
|
+
for (const doc of docs) {
|
|
1213
|
+
doc.stat = 3;
|
|
1214
|
+
delete doc.deleted_ts;
|
|
1215
|
+
delete doc.trash_root;
|
|
1216
|
+
delete doc.is_trash_root;
|
|
1217
|
+
}
|
|
1218
|
+
const save_ret = await db_module.sava_app_couch_bulk_docs(app_id_q, docs);
|
|
1219
|
+
if (save_ret.code < 0) throw new Error(save_ret.data);
|
|
1220
|
+
return { code: 200, data: { restored: docs.length } };
|
|
1221
|
+
} catch (err) {
|
|
1222
|
+
return { code: -200, data: err.message };
|
|
1223
|
+
}
|
|
1224
|
+
};
|
|
1225
|
+
|
|
1226
|
+
// req: { drive_type, app_id, uid, trash_roots: [paths] } — permanently removes
|
|
1227
|
+
// the batches: docs stay as stat=4 tombstones (same as delete_drive_files) but
|
|
1228
|
+
// lose their trash markers, and the stored bytes are cleaned up best-effort.
|
|
1229
|
+
export const purge_trashed_files = async (req) => {
|
|
1230
|
+
try {
|
|
1231
|
+
const { drive_type, app_id, uid, trash_roots } = req;
|
|
1232
|
+
_validate_trash_drive(drive_type);
|
|
1233
|
+
if (!Array.isArray(trash_roots) || !trash_roots.length) {
|
|
1234
|
+
return { code: -400, data: 'error - trash_roots must be a non-empty Array' };
|
|
1235
|
+
}
|
|
1236
|
+
const app_id_q = await _trash_app_id(drive_type, app_id, uid);
|
|
1237
|
+
const ret = await db_module.find_app_couch_query(app_id_q, {
|
|
1238
|
+
selector: { docType: `${drive_type}_drive`, stat: 4, trash_root: { $in: trash_roots } },
|
|
1239
|
+
limit: 10000,
|
|
1240
|
+
});
|
|
1241
|
+
const docs = ret?.data?.docs || ret?.docs || [];
|
|
1242
|
+
for (const doc of docs) {
|
|
1243
|
+
delete doc.trash_root;
|
|
1244
|
+
delete doc.is_trash_root;
|
|
1245
|
+
}
|
|
1246
|
+
const save_ret = await db_module.sava_app_couch_bulk_docs(app_id_q, docs);
|
|
1247
|
+
if (save_ret.code < 0) throw new Error(save_ret.data);
|
|
1248
|
+
|
|
1249
|
+
// Storage cleanup — mirrors delete_drive_files' deferred best-effort pass.
|
|
1250
|
+
setTimeout(async () => {
|
|
1251
|
+
for (const doc of docs) {
|
|
1252
|
+
if (doc.type !== 'file') continue;
|
|
1253
|
+
try {
|
|
1254
|
+
if (doc.bucket) {
|
|
1255
|
+
await delete_file_from_bucket(doc.bucket);
|
|
1256
|
+
} else if (drive_type === 'workspace') {
|
|
1257
|
+
const { data: app_obj } = await db_module.get_app_obj(app_id);
|
|
1258
|
+
if (app_obj?.app_type === 'datacenter') {
|
|
1259
|
+
const host = `root@${app_obj.app_hosting_server.ip}`;
|
|
1260
|
+
await _utils.run_ssh_script(`ssh ${host} "mv /var/xuda/workspace_drive/${doc.server_file_name} /tmp/;" `);
|
|
1261
|
+
}
|
|
1262
|
+
}
|
|
1263
|
+
} catch (error) {}
|
|
1264
|
+
}
|
|
1265
|
+
}, 1000);
|
|
1266
|
+
|
|
1267
|
+
return { code: 200, data: { purged: docs.length } };
|
|
1268
|
+
} catch (err) {
|
|
1269
|
+
return { code: -200, data: err.message };
|
|
1270
|
+
}
|
|
1271
|
+
};
|
|
1272
|
+
|
|
1273
|
+
// ─── Storage breakdown + duplicate finder (user + workspace) ─────────────────
|
|
1274
|
+
// One Mango sweep over the drive's file docs → totals by category + duplicate
|
|
1275
|
+
// groups (same name + same byte size), largest waste first.
|
|
1276
|
+
export const get_drive_breakdown = async (req) => {
|
|
1277
|
+
try {
|
|
1278
|
+
const { drive_type, app_id, uid } = req;
|
|
1279
|
+
validate_drive_type(drive_type);
|
|
1280
|
+
if (drive_type === 'studio') {
|
|
1281
|
+
return { code: -400, data: 'Breakdown is not supported for the studio drive yet' };
|
|
1282
|
+
}
|
|
1283
|
+
const app_id_q = await _trash_app_id(drive_type, app_id, uid);
|
|
1284
|
+
const ret = await db_module.find_app_couch_query(app_id_q, {
|
|
1285
|
+
selector: { docType: `${drive_type}_drive`, stat: 3, type: 'file' },
|
|
1286
|
+
fields: ['originalname', 'size', 'file_ext', 'mime', 'file_path'],
|
|
1287
|
+
limit: 50000,
|
|
1288
|
+
});
|
|
1289
|
+
const docs = ret?.data?.docs || ret?.docs || [];
|
|
1290
|
+
|
|
1291
|
+
const cat_of = (d) => {
|
|
1292
|
+
const mime = d.mime || '';
|
|
1293
|
+
const ext = (d.file_ext || '').replace('.', '').toLowerCase();
|
|
1294
|
+
if (mime.startsWith('image/') || ['png', 'jpg', 'jpeg', 'gif', 'webp', 'svg', 'tiff', 'psd'].includes(ext)) return 'images';
|
|
1295
|
+
if (mime.startsWith('video/') || ['mp4', 'mov', 'avi', 'webm'].includes(ext)) return 'video';
|
|
1296
|
+
if (mime.startsWith('audio/') || ['mp3', 'wav', 'ogg', 'flac'].includes(ext)) return 'audio';
|
|
1297
|
+
if (['pdf', 'doc', 'docx', 'txt', 'md', 'xls', 'xlsx', 'csv', 'ppt', 'pptx', 'plist'].includes(ext)) return 'documents';
|
|
1298
|
+
if (['zip', 'rar', '7z', 'tar', 'gz'].includes(ext)) return 'archives';
|
|
1299
|
+
if (['js', 'html', 'css', 'json', 'ts', 'vue', 'py'].includes(ext)) return 'code';
|
|
1300
|
+
return 'other';
|
|
1301
|
+
};
|
|
1302
|
+
|
|
1303
|
+
const by_type = {};
|
|
1304
|
+
const groups = {};
|
|
1305
|
+
let total = 0;
|
|
1306
|
+
for (const d of docs) {
|
|
1307
|
+
const size = d.size || 0;
|
|
1308
|
+
total += size;
|
|
1309
|
+
const cat = cat_of(d);
|
|
1310
|
+
if (!by_type[cat]) by_type[cat] = { type: cat, bytes: 0, count: 0 };
|
|
1311
|
+
by_type[cat].bytes += size;
|
|
1312
|
+
by_type[cat].count++;
|
|
1313
|
+
const key = (d.originalname || '') + '|' + size;
|
|
1314
|
+
if (!groups[key]) groups[key] = { name: d.originalname, size, count: 0, paths: [] };
|
|
1315
|
+
groups[key].count++;
|
|
1316
|
+
groups[key].paths.push(path.join(d.file_path || '/', d.originalname || ''));
|
|
1317
|
+
}
|
|
1318
|
+
const duplicates = Object.values(groups)
|
|
1319
|
+
.filter((g) => g.count > 1 && g.size > 0)
|
|
1320
|
+
.map((g) => ({ ...g, wasted: g.size * (g.count - 1) }))
|
|
1321
|
+
.sort((a, b) => b.wasted - a.wasted)
|
|
1322
|
+
.slice(0, 20);
|
|
1323
|
+
|
|
1324
|
+
return {
|
|
1325
|
+
code: 200,
|
|
1326
|
+
data: {
|
|
1327
|
+
total,
|
|
1328
|
+
count: docs.length,
|
|
1329
|
+
by_type: Object.values(by_type).sort((a, b) => b.bytes - a.bytes),
|
|
1330
|
+
duplicates,
|
|
1331
|
+
},
|
|
1332
|
+
};
|
|
1333
|
+
} catch (err) {
|
|
1334
|
+
return { code: -200, data: err.message };
|
|
1335
|
+
}
|
|
1336
|
+
};
|
|
1337
|
+
|
|
993
1338
|
export const update_drive_file_sharing_mode = async (req, job_id, headers) => {
|
|
994
1339
|
try {
|
|
995
1340
|
const { type, drive_type, uid, app_id, file_path, is_public } = req;
|
|
@@ -3238,6 +3583,80 @@ export const star_drive_file_user = async (req, job_id, headers, file_obj) => {
|
|
|
3238
3583
|
return await star_drive_file(req, job_id, headers, file_obj);
|
|
3239
3584
|
};
|
|
3240
3585
|
|
|
3586
|
+
export const move_drive_files_workspace = async (req, job_id, headers, file_obj) => {
|
|
3587
|
+
req.drive_type = 'workspace';
|
|
3588
|
+
return await move_drive_files(req, job_id, headers, file_obj);
|
|
3589
|
+
};
|
|
3590
|
+
export const move_drive_files_studio = _common.location_sensitive(async (req, job_id, headers, file_obj) => {
|
|
3591
|
+
req.drive_type = 'studio';
|
|
3592
|
+
return await move_drive_files(req, job_id, headers, file_obj);
|
|
3593
|
+
});
|
|
3594
|
+
export const move_drive_files_user = async (req, job_id, headers, file_obj) => {
|
|
3595
|
+
req.drive_type = 'user';
|
|
3596
|
+
if (!req.uid && req.token_ret?.data?.uid) req.uid = req.token_ret.data.uid; // user-drive ops resolve the project from the authenticated uid
|
|
3597
|
+
return await move_drive_files(req, job_id, headers, file_obj);
|
|
3598
|
+
};
|
|
3599
|
+
|
|
3600
|
+
export const get_drive_size_workspace = async (req, job_id, headers, file_obj) => {
|
|
3601
|
+
req.drive_type = 'workspace';
|
|
3602
|
+
return await get_drive_size(req, job_id, headers, file_obj);
|
|
3603
|
+
};
|
|
3604
|
+
export const get_drive_size_studio = _common.location_sensitive(async (req, job_id, headers, file_obj) => {
|
|
3605
|
+
req.drive_type = 'studio';
|
|
3606
|
+
return await get_drive_size(req, job_id, headers, file_obj);
|
|
3607
|
+
});
|
|
3608
|
+
export const get_drive_size_user = async (req, job_id, headers, file_obj) => {
|
|
3609
|
+
req.drive_type = 'user';
|
|
3610
|
+
if (!req.uid && req.token_ret?.data?.uid) req.uid = req.token_ret.data.uid; // user-drive ops resolve the project from the authenticated uid
|
|
3611
|
+
return await get_drive_size(req, job_id, headers, file_obj);
|
|
3612
|
+
};
|
|
3613
|
+
|
|
3614
|
+
export const trash_drive_files_workspace = async (req, job_id, headers, file_obj) => {
|
|
3615
|
+
req.drive_type = 'workspace';
|
|
3616
|
+
return await trash_drive_files(req, job_id, headers, file_obj);
|
|
3617
|
+
};
|
|
3618
|
+
export const trash_drive_files_user = async (req, job_id, headers, file_obj) => {
|
|
3619
|
+
req.drive_type = 'user';
|
|
3620
|
+
if (!req.uid && req.token_ret?.data?.uid) req.uid = req.token_ret.data.uid;
|
|
3621
|
+
return await trash_drive_files(req, job_id, headers, file_obj);
|
|
3622
|
+
};
|
|
3623
|
+
export const get_trashed_files_workspace = async (req, job_id, headers, file_obj) => {
|
|
3624
|
+
req.drive_type = 'workspace';
|
|
3625
|
+
return await get_trashed_files(req, job_id, headers, file_obj);
|
|
3626
|
+
};
|
|
3627
|
+
export const get_trashed_files_user = async (req, job_id, headers, file_obj) => {
|
|
3628
|
+
req.drive_type = 'user';
|
|
3629
|
+
if (!req.uid && req.token_ret?.data?.uid) req.uid = req.token_ret.data.uid;
|
|
3630
|
+
return await get_trashed_files(req, job_id, headers, file_obj);
|
|
3631
|
+
};
|
|
3632
|
+
export const restore_trashed_files_workspace = async (req, job_id, headers, file_obj) => {
|
|
3633
|
+
req.drive_type = 'workspace';
|
|
3634
|
+
return await restore_trashed_files(req, job_id, headers, file_obj);
|
|
3635
|
+
};
|
|
3636
|
+
export const restore_trashed_files_user = async (req, job_id, headers, file_obj) => {
|
|
3637
|
+
req.drive_type = 'user';
|
|
3638
|
+
if (!req.uid && req.token_ret?.data?.uid) req.uid = req.token_ret.data.uid;
|
|
3639
|
+
return await restore_trashed_files(req, job_id, headers, file_obj);
|
|
3640
|
+
};
|
|
3641
|
+
export const purge_trashed_files_workspace = async (req, job_id, headers, file_obj) => {
|
|
3642
|
+
req.drive_type = 'workspace';
|
|
3643
|
+
return await purge_trashed_files(req, job_id, headers, file_obj);
|
|
3644
|
+
};
|
|
3645
|
+
export const purge_trashed_files_user = async (req, job_id, headers, file_obj) => {
|
|
3646
|
+
req.drive_type = 'user';
|
|
3647
|
+
if (!req.uid && req.token_ret?.data?.uid) req.uid = req.token_ret.data.uid;
|
|
3648
|
+
return await purge_trashed_files(req, job_id, headers, file_obj);
|
|
3649
|
+
};
|
|
3650
|
+
export const get_drive_breakdown_workspace = async (req, job_id, headers, file_obj) => {
|
|
3651
|
+
req.drive_type = 'workspace';
|
|
3652
|
+
return await get_drive_breakdown(req, job_id, headers, file_obj);
|
|
3653
|
+
};
|
|
3654
|
+
export const get_drive_breakdown_user = async (req, job_id, headers, file_obj) => {
|
|
3655
|
+
req.drive_type = 'user';
|
|
3656
|
+
if (!req.uid && req.token_ret?.data?.uid) req.uid = req.token_ret.data.uid;
|
|
3657
|
+
return await get_drive_breakdown(req, job_id, headers, file_obj);
|
|
3658
|
+
};
|
|
3659
|
+
|
|
3241
3660
|
export const delete_file_bulk_workspace = async (req, job_id, headers, file_obj) => {
|
|
3242
3661
|
req.drive_type = 'workspace';
|
|
3243
3662
|
return await delete_file_bulk(req, job_id, headers, file_obj);
|