@xuda.io/drive_module 1.1.543 → 1.1.545

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.
Files changed (2) hide show
  1. package/index.js +26 -15
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -712,8 +712,9 @@ exports.update_drive_file = async function (req, job_id, headers, file_obj) {
712
712
  return {
713
713
  code: 760,
714
714
  data: {
715
- server_file_name: `https://${process.env.XUDA_HOSTNAME}/${req.drive_type === "studio" ? "uploads" : "drive"
716
- }${req.file_name}`,
715
+ server_file_name: `https://${process.env.XUDA_HOSTNAME}/${
716
+ req.drive_type === "studio" ? "uploads" : "drive"
717
+ }${req.file_name}`,
717
718
  filename: file_obj.originalname,
718
719
  },
719
720
  };
@@ -1287,7 +1288,7 @@ exports.extract_drive_file = async function (req, job_id, headers) {
1287
1288
 
1288
1289
  try {
1289
1290
  await db_module.save_app_couch_doc(app_id_reference, file_doc);
1290
- } catch (error) { }
1291
+ } catch (error) {}
1291
1292
  })
1292
1293
  .on("close", () => {
1293
1294
  console.log("Extraction complete.");
@@ -1332,7 +1333,7 @@ exports.delete_file_bulk = async function (req) {
1332
1333
 
1333
1334
  exports.upload_drive_file = async function (req, job_id, headers, file_obj) {
1334
1335
  try {
1335
- const { drive_type, app_id, uid, make_public } = req;
1336
+ const { drive_type, app_id, uid, make_public, override } = req;
1336
1337
 
1337
1338
  /// validations
1338
1339
  validate_drive_type(drive_type);
@@ -1426,15 +1427,22 @@ exports.upload_drive_file = async function (req, job_id, headers, file_obj) {
1426
1427
  file_name = file_obj.originalname;
1427
1428
  }
1428
1429
 
1429
- // target_file = path.join(
1430
- // req.path !== "/" ? req.path : target_dir,
1431
- // file_name
1432
- // );
1433
1430
  doc.server_file_name = file_name;
1434
1431
 
1435
1432
  doc.app_id = app_id;
1436
1433
  doc.app_id_reference = ref;
1437
1434
 
1435
+ /// check existing file
1436
+ if (!override) {
1437
+ const workspace_drive_res = await db_module.find_couch_query(
1438
+ "xuda_drive",
1439
+ {
1440
+ selector: { docType: "user_drive", ocr_stat: 1, stat: 3 },
1441
+ limit: 1,
1442
+ }
1443
+ );
1444
+ }
1445
+
1438
1446
  doc.bucket = {
1439
1447
  [`${process.env.XUDA_HOSTNAME}`]: await upload_file_to_spaces(
1440
1448
  tempPath,
@@ -1482,12 +1490,15 @@ exports.upload_drive_file = async function (req, job_id, headers, file_obj) {
1482
1490
  break;
1483
1491
  }
1484
1492
 
1485
- let file_url = `https://${process.env.XUDA_HOSTNAME
1486
- }/${drive_type}-drive/${ref}${file_name.substr(0, 1) !== "/" ? "/" : ""
1487
- }${file_name}`;
1493
+ let file_url = `https://${
1494
+ process.env.XUDA_HOSTNAME
1495
+ }/${drive_type}-drive/${ref}${
1496
+ file_name.substr(0, 1) !== "/" ? "/" : ""
1497
+ }${file_name}`;
1488
1498
  if (["workspace"].includes(req.drive_type)) {
1489
- file_url = `https://${process.env.XUDA_HOSTNAME}/workspace-drive${file_name.substr(0, 1) !== "/" ? "/" : ""
1490
- }${file_name}`;
1499
+ file_url = `https://${process.env.XUDA_HOSTNAME}/workspace-drive${
1500
+ file_name.substr(0, 1) !== "/" ? "/" : ""
1501
+ }${file_name}`;
1491
1502
  }
1492
1503
 
1493
1504
  await fs_module.unlink(tempPath);
@@ -2043,7 +2054,7 @@ const get_file_info = async function (file_path) {
2043
2054
  const sizeOf = require("image-size");
2044
2055
  const dimensions = sizeOf(file_path);
2045
2056
  doc.dimensions = `${dimensions.width}x${dimensions.height}`;
2046
- } catch (error) { }
2057
+ } catch (error) {}
2047
2058
  return doc;
2048
2059
  };
2049
2060
 
@@ -2102,4 +2113,4 @@ const get_folder_docs = async function (dir, drive_type, app_id) {
2102
2113
  return docs;
2103
2114
  };
2104
2115
 
2105
- setTimeout(function () { }, 2000);
2116
+ setTimeout(function () {}, 2000);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xuda.io/drive_module",
3
- "version": "1.1.543",
3
+ "version": "1.1.545",
4
4
  "description": "Xuda Drive Server Module",
5
5
  "main": "index.js",
6
6
  "dependencies": {