@xuda.io/drive_module 1.1.897 → 1.1.899

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 +64 -63
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -182,12 +182,11 @@ exports.get_drive_files = async function (req) {
182
182
  else return (bytes / 1073741824).toFixed(2) + " GB";
183
183
  }
184
184
 
185
- const process_drive_data = async function (ret, file_doc) {
185
+ const get_drive_files = async function (ret, file_doc) {
186
186
  let files = {
187
187
  path: req.path || "/",
188
188
  name: file_doc.data.folder_name || "/",
189
189
  file_path: req.path || "/",
190
- // size: 0,
191
190
  sizeInBytes: 0,
192
191
  children: [],
193
192
  };
@@ -202,10 +201,10 @@ exports.get_drive_files = async function (req) {
202
201
  size: formatBytes(doc.size),
203
202
  extension: doc?.file_ext?.substr(1),
204
203
  type: doc.type,
205
- access_link: `https://${process.env.XUDA_HOSTNAME}/workspace-drive/${app_id}/${doc._id}`, //?gtp_token=${gtp_token}
204
+ access_link: `https://${process.env.XUDA_HOSTNAME}/${drive_type}-drive/${app_id}/${doc._id}`,
206
205
  is_archive: doc.is_archive,
207
206
  public: doc.public,
208
- path: doc.file_path, // "/" + doc._id,
207
+ path: doc.file_path,
209
208
  date_created: doc.date_created,
210
209
  file_path: path.join(doc.file_path, doc.originalname),
211
210
  });
@@ -237,6 +236,8 @@ exports.get_drive_files = async function (req) {
237
236
  }
238
237
  }
239
238
  files.size = formatBytes(files.sizeInBytes);
239
+
240
+ return files;
240
241
  };
241
242
 
242
243
  const get_workspace_files = async function () {
@@ -260,66 +261,66 @@ exports.get_drive_files = async function (req) {
260
261
 
261
262
  const ret = await db_module.find_app_couch_query(app_id, opt);
262
263
 
263
- const file_doc = await db_module.get_app_couch_doc(
264
- app_id,
265
- path.basename(req.path) || "/"
266
- );
267
- // console.log(file_doc);
268
-
269
- let files = {
270
- path: req.path || "/",
271
- name: file_doc.data.folder_name || "/",
272
- file_path: req.path || "/",
273
- // size: 0,
274
- sizeInBytes: 0,
275
- children: [],
276
- };
264
+ // const file_doc = await db_module.get_app_couch_doc(
265
+ // app_id,
266
+ // path.basename(req.path) || "/"
267
+ // );
268
+ // // console.log(file_doc);
269
+
270
+ // let files = {
271
+ // path: req.path || "/",
272
+ // name: file_doc.data.folder_name || "/",
273
+ // file_path: req.path || "/",
274
+ // // size: 0,
275
+ // sizeInBytes: 0,
276
+ // children: [],
277
+ // };
277
278
 
278
- for await (let doc of ret.docs) {
279
- if (doc.type === "file") {
280
- try {
281
- files.sizeInBytes += doc.size;
282
- files.children.push({
283
- name: doc.originalname,
284
- sizeInBytes: doc.size,
285
- size: formatBytes(doc.size),
286
- extension: doc?.file_ext?.substr(1),
287
- type: doc.type,
288
- access_link: `https://${process.env.XUDA_HOSTNAME}/workspace-drive/${app_id}/${doc._id}`, //?gtp_token=${gtp_token}
289
- is_archive: doc.is_archive,
290
- public: doc.public,
291
- path: doc.file_path, // "/" + doc._id,
292
- date_created: doc.date_created,
293
- file_path: path.join(doc.file_path, doc.originalname),
294
- });
295
- } catch (err) {
296
- console.error(err.message);
297
- }
298
- }
299
- if (doc.type === "directory") {
300
- try {
301
- const sizeInBytes = await get_folder_size(
302
- req.path,
303
- drive_type,
304
- app_id_reference
305
- );
306
- files.sizeInBytes += sizeInBytes;
307
- files.children.push({
308
- sizeInBytes,
309
- size: formatBytes(sizeInBytes),
310
- name: doc.folder_name,
311
- path: "/" + doc._id,
312
- file_path: "/" + doc._id,
313
- type: doc.type,
314
- is_folder: true,
315
- date_created: doc.date_created,
316
- });
317
- } catch (err) {
318
- console.error(err.message);
319
- }
320
- }
321
- }
322
- files.size = formatBytes(files.sizeInBytes);
279
+ // for await (let doc of ret.docs) {
280
+ // if (doc.type === "file") {
281
+ // try {
282
+ // files.sizeInBytes += doc.size;
283
+ // files.children.push({
284
+ // name: doc.originalname,
285
+ // sizeInBytes: doc.size,
286
+ // size: formatBytes(doc.size),
287
+ // extension: doc?.file_ext?.substr(1),
288
+ // type: doc.type,
289
+ // access_link: `https://${process.env.XUDA_HOSTNAME}/workspace-drive/${app_id}/${doc._id}`, //?gtp_token=${gtp_token}
290
+ // is_archive: doc.is_archive,
291
+ // public: doc.public,
292
+ // path: doc.file_path, // "/" + doc._id,
293
+ // date_created: doc.date_created,
294
+ // file_path: path.join(doc.file_path, doc.originalname),
295
+ // });
296
+ // } catch (err) {
297
+ // console.error(err.message);
298
+ // }
299
+ // }
300
+ // if (doc.type === "directory") {
301
+ // try {
302
+ // const sizeInBytes = await get_folder_size(
303
+ // req.path,
304
+ // drive_type,
305
+ // app_id_reference
306
+ // );
307
+ // files.sizeInBytes += sizeInBytes;
308
+ // files.children.push({
309
+ // sizeInBytes,
310
+ // size: formatBytes(sizeInBytes),
311
+ // name: doc.folder_name,
312
+ // path: "/" + doc._id,
313
+ // file_path: "/" + doc._id,
314
+ // type: doc.type,
315
+ // is_folder: true,
316
+ // date_created: doc.date_created,
317
+ // });
318
+ // } catch (err) {
319
+ // console.error(err.message);
320
+ // }
321
+ // }
322
+ // }
323
+ // files.size = formatBytes(files.sizeInBytes);
323
324
 
324
325
  return { code: 1, data: await process_drive_data(ret, file_doc) };
325
326
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xuda.io/drive_module",
3
- "version": "1.1.897",
3
+ "version": "1.1.899",
4
4
  "description": "Xuda Drive Server Module",
5
5
  "main": "index.js",
6
6
  "dependencies": {