@xuda.io/drive_module 1.1.1194 → 1.1.1196

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 +9 -19
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -4,6 +4,7 @@ console.log('drive module loaded..');
4
4
 
5
5
  const _common = require(path.join(process.env.XUDA_HOME, 'common', 'xuda_node_common.js'));
6
6
  const _utils = require(path.join(process.env.XUDA_HOME, 'common', 'xuda-cpi-utils.js'));
7
+
7
8
  const _ = require('lodash');
8
9
 
9
10
  const module_path = path.join(process.env.XUDA_HOME, 'cpi') + (!_conf.is_debug ? '/node_modules/@xuda.io' : '');
@@ -614,7 +615,14 @@ exports.update_drive_file = async function (req, job_id, headers, file_obj) {
614
615
  const app_id_master = await _common.get_project_app_id(app_id, true);
615
616
  ref = app_id_master;
616
617
 
617
- doc.bucket[`${process.env.XUDA_HOSTNAME}`] = await upload_file_to_spaces(tempPath, app_id_master, drive_type, file_name);
618
+ const { data: app_obj } = await db_module.get_app_obj(app_id);
619
+ if (app_obj?.app_type === 'datacenter') {
620
+ //app_obj.is_deployment // not possible, every deployment will have is own upload mechanism
621
+ const host = `root@${app_obj.app_hosting_server.ip}`;
622
+ await _utils.run_ssh_script(`scp ${tempPath} ${host}:/var/xuda/workspace_drive/${file_name}; `);
623
+ } else {
624
+ doc.bucket[`${process.env.XUDA_HOSTNAME}`] = await upload_file_to_spaces(tempPath, app_id_master, drive_type, file_name);
625
+ }
618
626
 
619
627
  save_ret = await db_module.save_app_couch_doc(app_id_reference, doc);
620
628
  // misc_module.rsync_drive_resources_to_remote_servers('workspace', app_id_master);
@@ -1158,24 +1166,6 @@ exports.upload_drive_file = async function (req, job_id, headers, file_obj) {
1158
1166
  doc.app_id = app_id;
1159
1167
  doc.app_id_reference = ref;
1160
1168
 
1161
- /// check existing file
1162
- // if (check_exist) {
1163
- // const workspace_drive_res = await db_module.find_app_couch_query(
1164
- // app_id,
1165
- // {
1166
- // selector: { docType: "workspace_drive", originalname, stat: 3 },
1167
- // limit: 99,
1168
- // }
1169
- // );
1170
- // if (workspace_drive_res.docs.length) {
1171
- // return {
1172
- // code: -762,
1173
- // data: "file already exist",
1174
- // duplicates: workspace_drive_res.docs,
1175
- // };
1176
- // }
1177
- // }
1178
- debugger;
1179
1169
  // if file uploaded from deployment or from datacenter then save to the datacenter server fs
1180
1170
  const { data: app_obj } = await db_module.get_app_obj(app_id);
1181
1171
  if (app_obj?.app_type === 'datacenter') {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xuda.io/drive_module",
3
- "version": "1.1.1194",
3
+ "version": "1.1.1196",
4
4
  "description": "Xuda Drive Server Module",
5
5
  "main": "index.js",
6
6
  "dependencies": {