@xuda.io/drive_module 1.1.902 → 1.1.904

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 +80 -73
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -328,87 +328,94 @@ exports.get_drive_files = async function (req) {
328
328
  // }
329
329
  // files.size = formatBytes(files.sizeInBytes);
330
330
 
331
- return { code: 1, data: await get_drive_files(ret, file_doc) };
331
+ return {
332
+ code: 1,
333
+ data: await get_drive_files(ret, file_doc, app_id_reference, null),
334
+ };
332
335
  };
333
336
  const get_user_files = async function () {
334
337
  opt.selector.docType = "user_drive";
335
338
  opt.selector.uid = uid;
336
- // var opt = {
337
- // selector: {
338
- // docType: "user_drive",
339
- // stat: 3,
340
- // uid,
341
- // type,
342
- // file_path: req.path,
343
- // },
344
- // limit: to - from,
345
- // skip: from,
339
+ // // var opt = {
340
+ // // selector: {
341
+ // // docType: "user_drive",
342
+ // // stat: 3,
343
+ // // uid,
344
+ // // type,
345
+ // // file_path: req.path,
346
+ // // },
347
+ // // limit: to - from,
348
+ // // skip: from,
349
+ // // };
350
+
351
+ // // if (date) {
352
+ // // opt.sort = [{ date_created: "desc" }];
353
+ // // }
354
+
355
+ // const ret = await db_module.find_couch_query("xuda_drive", opt);
356
+ // const file_doc = await db_module.get_couch_doc(
357
+ // "xuda_drive",
358
+ // path.basename(req.path) || "/"
359
+ // );
360
+ // // console.log(file_doc);
361
+
362
+ // let files = {
363
+ // name: file_doc.data.folder_name || "/",
364
+ // path: req.path || "/",
365
+ // file_path: req.path || "/",
366
+ // sizeInBytes: 0,
367
+ // children: [],
346
368
  // };
347
369
 
348
- // if (date) {
349
- // opt.sort = [{ date_created: "desc" }];
370
+ // for await (let doc of ret.docs) {
371
+ // if (doc.type === "file") {
372
+ // try {
373
+ // files.sizeInBytes += doc.size;
374
+ // files.children.push({
375
+ // name: doc.originalname,
376
+ // sizeInBytes: doc.size,
377
+ // size: formatBytes(doc.size),
378
+ // extension: doc?.file_ext?.substr(1),
379
+ // type: doc.type,
380
+ // access_link: `https://${process.env.XUDA_HOSTNAME}/user-drive/${uid}/${doc._id}`,
381
+ // is_archive: doc.is_archive,
382
+ // public: doc.public,
383
+ // path: doc.file_path, // "/" + doc._id,
384
+ // date_created: doc.date_created,
385
+ // file_path: path.join(doc.file_path, doc.originalname),
386
+ // });
387
+ // } catch (err) {
388
+ // console.error(err.message);
389
+ // }
390
+ // }
391
+ // if (doc.type === "directory") {
392
+ // try {
393
+ // const sizeInBytes = await get_folder_size(
394
+ // req.path,
395
+ // drive_type,
396
+ // null,
397
+ // uid
398
+ // );
399
+ // files.sizeInBytes += sizeInBytes;
400
+ // files.children.push({
401
+ // sizeInBytes,
402
+ // size: formatBytes(sizeInBytes),
403
+ // name: doc.folder_name,
404
+ // path: "/" + doc._id,
405
+ // file_path: "/" + doc._id,
406
+ // date_created: doc.date_created,
407
+ // });
408
+ // } catch (err) {
409
+ // console.error(err.message);
410
+ // }
411
+ // }
350
412
  // }
351
-
352
- const ret = await db_module.find_couch_query("xuda_drive", opt);
353
- const file_doc = await db_module.get_couch_doc(
354
- "xuda_drive",
355
- path.basename(req.path) || "/"
356
- );
357
- // console.log(file_doc);
358
-
359
- let files = {
360
- name: file_doc.data.folder_name || "/",
361
- path: req.path || "/",
362
- file_path: req.path || "/",
363
- sizeInBytes: 0,
364
- children: [],
413
+ // files.size = formatBytes(files.size);
414
+ // return { code: 1, data: files };
415
+ return {
416
+ code: 1,
417
+ data: await get_drive_files(ret, file_doc, null, uid),
365
418
  };
366
-
367
- for await (let doc of ret.docs) {
368
- if (doc.type === "file") {
369
- try {
370
- files.sizeInBytes += doc.size;
371
- files.children.push({
372
- name: doc.originalname,
373
- sizeInBytes: doc.size,
374
- size: formatBytes(doc.size),
375
- extension: doc?.file_ext?.substr(1),
376
- type: doc.type,
377
- access_link: `https://${process.env.XUDA_HOSTNAME}/user-drive/${uid}/${doc._id}`,
378
- is_archive: doc.is_archive,
379
- public: doc.public,
380
- path: doc.file_path, // "/" + doc._id,
381
- date_created: doc.date_created,
382
- file_path: path.join(doc.file_path, doc.originalname),
383
- });
384
- } catch (err) {
385
- console.error(err.message);
386
- }
387
- }
388
- if (doc.type === "directory") {
389
- try {
390
- const sizeInBytes = await get_folder_size(
391
- req.path,
392
- drive_type,
393
- null,
394
- uid
395
- );
396
- files.sizeInBytes += sizeInBytes;
397
- files.children.push({
398
- sizeInBytes,
399
- size: formatBytes(sizeInBytes),
400
- name: doc.folder_name,
401
- path: "/" + doc._id,
402
- file_path: "/" + doc._id,
403
- date_created: doc.date_created,
404
- });
405
- } catch (err) {
406
- console.error(err.message);
407
- }
408
- }
409
- }
410
- files.size = formatBytes(files.size);
411
- return { code: 1, data: files };
412
419
  };
413
420
  const get_studio_files = async function () {
414
421
  const app_id_master = await _common.get_project_app_id(app_id, true);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xuda.io/drive_module",
3
- "version": "1.1.902",
3
+ "version": "1.1.904",
4
4
  "description": "Xuda Drive Server Module",
5
5
  "main": "index.js",
6
6
  "dependencies": {