@xuda.io/drive_module 1.1.903 → 1.1.905

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 +87 -72
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -336,84 +336,99 @@ exports.get_drive_files = async function (req) {
336
336
  const get_user_files = async function () {
337
337
  opt.selector.docType = "user_drive";
338
338
  opt.selector.uid = uid;
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,
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: [],
349
368
  // };
350
369
 
351
- // if (date) {
352
- // 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
+ // }
353
412
  // }
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: [],
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),
368
418
  };
369
-
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
- }
412
- }
413
- files.size = formatBytes(files.size);
414
- return { code: 1, data: files };
415
419
  };
416
420
  const get_studio_files = async function () {
421
+ if (search_string) {
422
+ const app_id_reference = await _common.get_project_app_id(app_id);
423
+ opt.selector.docType = "workspace_drive";
424
+ const ret = await db_module.find_app_couch_query(app_id, opt);
425
+
426
+ const file_doc = await db_module.get_app_couch_doc(
427
+ app_id,
428
+ path.basename(req.path) || "/"
429
+ );
430
+ }
431
+
417
432
  const app_id_master = await _common.get_project_app_id(app_id, true);
418
433
 
419
434
  var directoryPath =
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xuda.io/drive_module",
3
- "version": "1.1.903",
3
+ "version": "1.1.905",
4
4
  "description": "Xuda Drive Server Module",
5
5
  "main": "index.js",
6
6
  "dependencies": {