@xuda.io/drive_module 1.1.1117 → 1.1.1119

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 +20 -19
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -217,9 +217,8 @@ exports.get_drive_files = async function (req) {
217
217
  size: formatBytes(doc.size),
218
218
  extension: doc?.file_ext?.substr(1),
219
219
  type: doc.type,
220
- access_link: `https://${domain}/${drive_type}-drive/${
221
- datasource_id || app_id
222
- }/${doc._id}`,
220
+ access_link: `https://${domain}/${drive_type}-drive/${datasource_id || app_id
221
+ }/${doc._id}`,
223
222
  is_archive: doc.is_archive,
224
223
  public: doc.public,
225
224
  path: doc.file_path,
@@ -653,7 +652,7 @@ exports.update_drive_file = async function (req, job_id, headers, file_obj) {
653
652
  );
654
653
  try {
655
654
  fse.unlinkSync(target_dir);
656
- } catch (error) {}
655
+ } catch (error) { }
657
656
 
658
657
  fse.copyFileSync(tempPath, target_dir);
659
658
  }
@@ -669,9 +668,10 @@ exports.update_drive_file = async function (req, job_id, headers, file_obj) {
669
668
  doc = { ...doc, ...(await get_file_info(tempPath)) };
670
669
 
671
670
  let save_ret;
672
-
671
+ let ref
673
672
  switch (drive_type) {
674
673
  case "studio": {
674
+ ref = await _common.get_project_app_id(app_id, true);
675
675
  const app_id_reference = await _common.get_project_app_id(app_id);
676
676
  save_ret = await db_module.save_app_couch_doc(app_id_reference, doc);
677
677
 
@@ -682,8 +682,10 @@ exports.update_drive_file = async function (req, job_id, headers, file_obj) {
682
682
  break;
683
683
  }
684
684
  case "workspace": {
685
+
685
686
  const app_id_reference = await _common.get_project_app_id(app_id);
686
687
  const app_id_master = await _common.get_project_app_id(app_id, true);
688
+ ref = app_id_master;
687
689
 
688
690
  doc.bucket[`${process.env.XUDA_HOSTNAME}`] =
689
691
  await upload_file_to_spaces(
@@ -701,6 +703,7 @@ exports.update_drive_file = async function (req, job_id, headers, file_obj) {
701
703
  break;
702
704
  }
703
705
  case "user": {
706
+ ref = uid;
704
707
  doc.bucket[`${process.env.XUDA_HOSTNAME}`] =
705
708
  await upload_file_to_spaces(tempPath, uid, drive_type, file_name);
706
709
  save_ret = await db_module.save_couch_doc("xuda_drive", doc);
@@ -716,11 +719,11 @@ exports.update_drive_file = async function (req, job_id, headers, file_obj) {
716
719
  if (save_ret.code < 0) {
717
720
  return save_ret;
718
721
  }
719
- const server_file_name = `https://${
720
- process.env.XUDA_HOSTNAME
721
- }/${drive_type}-drive${
722
- drive_type === "studio" ? `/${master_id}/${target_file}` : file_name
723
- }`;
722
+ const server_file_name = `https://${process.env.XUDA_HOSTNAME
723
+ }/${drive_type}-drive${drive_type === "studio" ? `/${master_id}/${target_file}` : file_name
724
+ }`;
725
+
726
+ let file_url = get_file_url(drive_type, file_name, ref);
724
727
 
725
728
  misc_module.purge_cloudflare_cache(false, server_file_name);
726
729
  return {
@@ -1108,7 +1111,7 @@ exports.extract_drive_file = async function (req, job_id, headers) {
1108
1111
 
1109
1112
  try {
1110
1113
  await db_module.save_app_couch_doc(app_id_reference, file_doc);
1111
- } catch (error) {}
1114
+ } catch (error) { }
1112
1115
  })
1113
1116
  .on("close", () => {
1114
1117
  console.log("Extraction complete.");
@@ -1182,7 +1185,7 @@ exports.upload_drive_file = async function (req, job_id, headers, file_obj) {
1182
1185
  let tags_arr = [];
1183
1186
  try {
1184
1187
  if (tags) tags_arr = tags.split(",");
1185
- } catch (error) {}
1188
+ } catch (error) { }
1186
1189
 
1187
1190
  var doc = {
1188
1191
  docType: `${drive_type}_drive`,
@@ -1870,7 +1873,7 @@ const get_file_info = async function (file_path) {
1870
1873
  const sizeOf = require("image-size");
1871
1874
  const dimensions = sizeOf(file_path);
1872
1875
  doc.dimensions = `${dimensions.width}x${dimensions.height}`;
1873
- } catch (error) {}
1876
+ } catch (error) { }
1874
1877
  return doc;
1875
1878
  };
1876
1879
 
@@ -1957,11 +1960,9 @@ exports.update_drive_file_tags = async function (req, job_id, headers) {
1957
1960
  };
1958
1961
 
1959
1962
  const get_file_url = function (drive_type, file_name, ref) {
1960
- let file_url = `https://${
1961
- process.env.XUDA_HOSTNAME
1962
- }/${drive_type}-drive/${ref}${
1963
- file_name?.substr(0, 1) !== "/" ? "/" : ""
1964
- }${file_name}`;
1963
+ let file_url = `https://${process.env.XUDA_HOSTNAME
1964
+ }/${drive_type}-drive/${ref}${file_name?.substr(0, 1) !== "/" ? "/" : ""
1965
+ }${file_name}`;
1965
1966
  // if (["workspace"].includes(drive_type)) {
1966
1967
  // file_url = `https://${process.env.XUDA_HOSTNAME}/workspace-drive${
1967
1968
  // file_name.substr(0, 1) !== "/" ? "/" : ""
@@ -2153,7 +2154,7 @@ exports.compile_javascript_program_in_studio_drive = async function (
2153
2154
  const wrappedCode = [
2154
2155
  ...importLines,
2155
2156
  "",
2156
- "export default async function (xu, SESSION_ID, SESSION_OBJ, job_id) {",
2157
+ "export default async function (params,xu, SESSION_ID, SESSION_OBJ, job_id) {",
2157
2158
  ...codeLines.map((line) => ` ${line}`), // Indent the code inside the function
2158
2159
  "}",
2159
2160
  ];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xuda.io/drive_module",
3
- "version": "1.1.1117",
3
+ "version": "1.1.1119",
4
4
  "description": "Xuda Drive Server Module",
5
5
  "main": "index.js",
6
6
  "dependencies": {