@xuda.io/drive_module 1.1.1468 → 1.1.1469
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 +66 -1
- package/package.json +1 -1
package/index.mjs
CHANGED
|
@@ -1288,7 +1288,7 @@ export const upload_drive_file = async (req, job_id, headers = {}, file_obj) =>
|
|
|
1288
1288
|
return { code: -400, data: err.message };
|
|
1289
1289
|
}
|
|
1290
1290
|
};
|
|
1291
|
-
|
|
1291
|
+
const check_single_drive_file = async (req, job_id, headers, file_obj) => {
|
|
1292
1292
|
const { type = 'file', drive_type, app_id, uid, file_path, folder_name } = req;
|
|
1293
1293
|
|
|
1294
1294
|
let master_app_id;
|
|
@@ -1382,6 +1382,59 @@ export const check_drive_file = async (req, job_id, headers, file_obj) => {
|
|
|
1382
1382
|
};
|
|
1383
1383
|
};
|
|
1384
1384
|
|
|
1385
|
+
export const check_drive_files = async (req, job_id, headers, file_obj) => {
|
|
1386
|
+
const files = req.files ||
|
|
1387
|
+
req.file_paths?.map((curr_file_path) => ({
|
|
1388
|
+
file_path: curr_file_path,
|
|
1389
|
+
})) || [
|
|
1390
|
+
{
|
|
1391
|
+
file_path: req.file_path,
|
|
1392
|
+
folder_name: req.folder_name,
|
|
1393
|
+
type: req.type,
|
|
1394
|
+
},
|
|
1395
|
+
];
|
|
1396
|
+
|
|
1397
|
+
const results = [];
|
|
1398
|
+
|
|
1399
|
+
for (const item of files) {
|
|
1400
|
+
results.push(
|
|
1401
|
+
await check_single_drive_file(
|
|
1402
|
+
{
|
|
1403
|
+
...req,
|
|
1404
|
+
...item,
|
|
1405
|
+
},
|
|
1406
|
+
job_id,
|
|
1407
|
+
headers,
|
|
1408
|
+
file_obj,
|
|
1409
|
+
),
|
|
1410
|
+
);
|
|
1411
|
+
}
|
|
1412
|
+
|
|
1413
|
+
const duplicates = results.flatMap((item) => item?.duplicates || []);
|
|
1414
|
+
const has_duplicates = results.some((item) => item?.code < 0);
|
|
1415
|
+
|
|
1416
|
+
return {
|
|
1417
|
+
code: has_duplicates ? -764 : 764,
|
|
1418
|
+
data: has_duplicates ? 'one or more files exist' : 'ok',
|
|
1419
|
+
files: results,
|
|
1420
|
+
duplicates,
|
|
1421
|
+
};
|
|
1422
|
+
};
|
|
1423
|
+
|
|
1424
|
+
export const check_drive_file = async (req, job_id, headers, file_obj) => {
|
|
1425
|
+
const ret = await check_drive_files(req, job_id, headers, file_obj);
|
|
1426
|
+
|
|
1427
|
+
if (!ret.files?.length) {
|
|
1428
|
+
return {
|
|
1429
|
+
code: -764,
|
|
1430
|
+
data: 'no files to check',
|
|
1431
|
+
duplicates: [],
|
|
1432
|
+
};
|
|
1433
|
+
}
|
|
1434
|
+
|
|
1435
|
+
return ret.files[0];
|
|
1436
|
+
};
|
|
1437
|
+
|
|
1385
1438
|
const ocr_drive_file = async (app_id, doc) => {
|
|
1386
1439
|
const { drive_type, uid, file_path, originalname } = doc;
|
|
1387
1440
|
|
|
@@ -2311,14 +2364,26 @@ export const check_drive_file_workspace = async (req, job_id, headers, file_obj)
|
|
|
2311
2364
|
req.drive_type = 'workspace';
|
|
2312
2365
|
return await check_drive_file(req, job_id, headers, file_obj);
|
|
2313
2366
|
};
|
|
2367
|
+
export const check_drive_files_workspace = async (req, job_id, headers, file_obj) => {
|
|
2368
|
+
req.drive_type = 'workspace';
|
|
2369
|
+
return await check_drive_files(req, job_id, headers, file_obj);
|
|
2370
|
+
};
|
|
2314
2371
|
export const check_drive_file_studio = async (req, job_id, headers, file_obj) => {
|
|
2315
2372
|
req.drive_type = 'studio';
|
|
2316
2373
|
return await check_drive_file(req, job_id, headers, file_obj);
|
|
2317
2374
|
};
|
|
2375
|
+
export const check_drive_files_studio = async (req, job_id, headers, file_obj) => {
|
|
2376
|
+
req.drive_type = 'studio';
|
|
2377
|
+
return await check_drive_files(req, job_id, headers, file_obj);
|
|
2378
|
+
};
|
|
2318
2379
|
export const check_drive_file_user = async (req, job_id, headers, file_obj) => {
|
|
2319
2380
|
req.drive_type = 'user';
|
|
2320
2381
|
return await check_drive_file(req, job_id, headers, file_obj);
|
|
2321
2382
|
};
|
|
2383
|
+
export const check_drive_files_user = async (req, job_id, headers, file_obj) => {
|
|
2384
|
+
req.drive_type = 'user';
|
|
2385
|
+
return await check_drive_files(req, job_id, headers, file_obj);
|
|
2386
|
+
};
|
|
2322
2387
|
|
|
2323
2388
|
export const update_drive_file_tags_workspace = async (req, job_id, headers, file_obj) => {
|
|
2324
2389
|
req.drive_type = 'workspace';
|