@xuda.io/drive_module 1.1.1198 → 1.1.1200

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 +14 -3
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -513,7 +513,15 @@ exports.delete_drive_files = async function (req, job_id, headers) {
513
513
  const app_id_reference = await _common.get_project_app_id(app_id);
514
514
 
515
515
  if (doc.type === 'file') {
516
- await module.exports.delete_file_from_bucket(doc.bucket);
516
+ if (doc.bucket) {
517
+ await module.exports.delete_file_from_bucket(doc.bucket);
518
+ } else {
519
+ const { data: app_obj } = await db_module.get_app_obj(app_id);
520
+ if (app_obj?.app_type === 'datacenter') {
521
+ const host = `root@${app_obj.app_hosting_server.ip}`;
522
+ await _utils.run_ssh_script(`scp ${tempPath} ${host}:/var/xuda/workspace_drive/${file_name}; `);
523
+ }
524
+ }
517
525
  }
518
526
 
519
527
  doc.ts = Date.now();
@@ -1172,9 +1180,12 @@ exports.upload_drive_file = async function (req, job_id, headers, file_obj) {
1172
1180
  // if file uploaded from deployment or from datacenter then save to the datacenter server fs
1173
1181
  const { data: app_obj } = await db_module.get_app_obj(app_id);
1174
1182
  if (app_obj?.app_type === 'datacenter') {
1175
- //app_obj.is_deployment // not possible, every deployment will have is own upload mechanism
1176
1183
  const host = `root@${app_obj.app_hosting_server.ip}`;
1177
1184
  await _utils.run_ssh_script(`scp ${tempPath} ${host}:/var/xuda/workspace_drive/${file_name}; `);
1185
+ } else if (app_obj?.is_deployment) {
1186
+ const { data: datacenter_obj } = await db_module.get_app_obj(app_obj.app_datacenter_id);
1187
+ const host = `root@${datacenter_obj.app_hosting_server.ip}`;
1188
+ await _utils.run_ssh_script(`scp ${tempPath} ${host}:/var/xuda/workspace_drive/${file_name}; `);
1178
1189
  } else {
1179
1190
  doc.bucket = {
1180
1191
  [`${process.env.XUDA_HOSTNAME}`]: await upload_file_to_spaces(tempPath, ref, drive_type, file_name),
@@ -1332,7 +1343,7 @@ const ocr_drive_file = async function (app_id, doc) {
1332
1343
  // const _region = process.env.XUDA_HOSTNAME;
1333
1344
  let target_file = get_file_url(drive_type, path.join(file_path, doc._id), app_id || uid); // doc?.bucket?.[_region]?.Location;
1334
1345
 
1335
- if (!target_file) throw 'bucket not find';
1346
+ // if (!target_file) throw 'bucket not find';
1336
1347
 
1337
1348
  function addQueryParam(urlString, key, value) {
1338
1349
  // Parse the URL
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xuda.io/drive_module",
3
- "version": "1.1.1198",
3
+ "version": "1.1.1200",
4
4
  "description": "Xuda Drive Server Module",
5
5
  "main": "index.js",
6
6
  "dependencies": {