@xuda.io/drive_module 1.1.1017 → 1.1.1018
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.
- package/index.js +1 -147
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -258,83 +258,12 @@ exports.get_drive_files = async function (req) {
|
|
|
258
258
|
const app_id_reference = await _common.get_project_app_id(app_id);
|
|
259
259
|
opt.selector.docType = "workspace_drive";
|
|
260
260
|
|
|
261
|
-
// var opt = {
|
|
262
|
-
// selector: {
|
|
263
|
-
// docType: "workspace_drive",
|
|
264
|
-
// stat: 3,
|
|
265
|
-
// type,
|
|
266
|
-
// file_path: req.path,
|
|
267
|
-
// },
|
|
268
|
-
// limit: to - from,
|
|
269
|
-
// skip: from,
|
|
270
|
-
// };
|
|
271
|
-
|
|
272
|
-
// if (date) {
|
|
273
|
-
// opt.sort = [{ date_created: "desc" }];
|
|
274
|
-
// }
|
|
275
|
-
|
|
276
261
|
const ret = await db_module.find_app_couch_query(app_id, opt);
|
|
277
262
|
|
|
278
263
|
const file_doc = await db_module.get_app_couch_doc(
|
|
279
264
|
app_id,
|
|
280
265
|
path.basename(req.path) || "/"
|
|
281
266
|
);
|
|
282
|
-
// // console.log(file_doc);
|
|
283
|
-
|
|
284
|
-
// let files = {
|
|
285
|
-
// path: req.path || "/",
|
|
286
|
-
// name: file_doc.data.folder_name || "/",
|
|
287
|
-
// file_path: req.path || "/",
|
|
288
|
-
// // size: 0,
|
|
289
|
-
// sizeInBytes: 0,
|
|
290
|
-
// children: [],
|
|
291
|
-
// };
|
|
292
|
-
|
|
293
|
-
// for await (let doc of ret.docs) {
|
|
294
|
-
// if (doc.type === "file") {
|
|
295
|
-
// try {
|
|
296
|
-
// files.sizeInBytes += doc.size;
|
|
297
|
-
// files.children.push({
|
|
298
|
-
// name: doc.originalname,
|
|
299
|
-
// sizeInBytes: doc.size,
|
|
300
|
-
// size: formatBytes(doc.size),
|
|
301
|
-
// extension: doc?.file_ext?.substr(1),
|
|
302
|
-
// type: doc.type,
|
|
303
|
-
// access_link: `https://${process.env.XUDA_HOSTNAME}/workspace-drive/${app_id}/${doc._id}`, //?gtp_token=${gtp_token}
|
|
304
|
-
// is_archive: doc.is_archive,
|
|
305
|
-
// public: doc.public,
|
|
306
|
-
// path: doc.file_path, // "/" + doc._id,
|
|
307
|
-
// date_created: doc.date_created,
|
|
308
|
-
// file_path: path.join(doc.file_path, doc.originalname),
|
|
309
|
-
// });
|
|
310
|
-
// } catch (err) {
|
|
311
|
-
// console.error(err.message);
|
|
312
|
-
// }
|
|
313
|
-
// }
|
|
314
|
-
// if (doc.type === "directory") {
|
|
315
|
-
// try {
|
|
316
|
-
// const sizeInBytes = await get_folder_size(
|
|
317
|
-
// req.path,
|
|
318
|
-
// drive_type,
|
|
319
|
-
// app_id_reference
|
|
320
|
-
// );
|
|
321
|
-
// files.sizeInBytes += sizeInBytes;
|
|
322
|
-
// files.children.push({
|
|
323
|
-
// sizeInBytes,
|
|
324
|
-
// size: formatBytes(sizeInBytes),
|
|
325
|
-
// name: doc.folder_name,
|
|
326
|
-
// path: "/" + doc._id,
|
|
327
|
-
// file_path: "/" + doc._id,
|
|
328
|
-
// type: doc.type,
|
|
329
|
-
// is_folder: true,
|
|
330
|
-
// date_created: doc.date_created,
|
|
331
|
-
// });
|
|
332
|
-
// } catch (err) {
|
|
333
|
-
// console.error(err.message);
|
|
334
|
-
// }
|
|
335
|
-
// }
|
|
336
|
-
// }
|
|
337
|
-
// files.size = formatBytes(files.sizeInBytes);
|
|
338
267
|
|
|
339
268
|
return {
|
|
340
269
|
code: 1,
|
|
@@ -344,82 +273,7 @@ exports.get_drive_files = async function (req) {
|
|
|
344
273
|
const get_user_files = async function () {
|
|
345
274
|
opt.selector.docType = "user_drive";
|
|
346
275
|
opt.selector.uid = uid;
|
|
347
|
-
|
|
348
|
-
// // selector: {
|
|
349
|
-
// // docType: "user_drive",
|
|
350
|
-
// // stat: 3,
|
|
351
|
-
// // uid,
|
|
352
|
-
// // type,
|
|
353
|
-
// // file_path: req.path,
|
|
354
|
-
// // },
|
|
355
|
-
// // limit: to - from,
|
|
356
|
-
// // skip: from,
|
|
357
|
-
// // };
|
|
358
|
-
|
|
359
|
-
// // if (date) {
|
|
360
|
-
// // opt.sort = [{ date_created: "desc" }];
|
|
361
|
-
// // }
|
|
362
|
-
|
|
363
|
-
// const ret = await db_module.find_couch_query("xuda_drive", opt);
|
|
364
|
-
// const file_doc = await db_module.get_couch_doc(
|
|
365
|
-
// "xuda_drive",
|
|
366
|
-
// path.basename(req.path) || "/"
|
|
367
|
-
// );
|
|
368
|
-
// // console.log(file_doc);
|
|
369
|
-
|
|
370
|
-
// let files = {
|
|
371
|
-
// name: file_doc.data.folder_name || "/",
|
|
372
|
-
// path: req.path || "/",
|
|
373
|
-
// file_path: req.path || "/",
|
|
374
|
-
// sizeInBytes: 0,
|
|
375
|
-
// children: [],
|
|
376
|
-
// };
|
|
377
|
-
|
|
378
|
-
// for await (let doc of ret.docs) {
|
|
379
|
-
// if (doc.type === "file") {
|
|
380
|
-
// try {
|
|
381
|
-
// files.sizeInBytes += doc.size;
|
|
382
|
-
// files.children.push({
|
|
383
|
-
// name: doc.originalname,
|
|
384
|
-
// sizeInBytes: doc.size,
|
|
385
|
-
// size: formatBytes(doc.size),
|
|
386
|
-
// extension: doc?.file_ext?.substr(1),
|
|
387
|
-
// type: doc.type,
|
|
388
|
-
// access_link: `https://${process.env.XUDA_HOSTNAME}/user-drive/${uid}/${doc._id}`,
|
|
389
|
-
// is_archive: doc.is_archive,
|
|
390
|
-
// public: doc.public,
|
|
391
|
-
// path: doc.file_path, // "/" + doc._id,
|
|
392
|
-
// date_created: doc.date_created,
|
|
393
|
-
// file_path: path.join(doc.file_path, doc.originalname),
|
|
394
|
-
// });
|
|
395
|
-
// } catch (err) {
|
|
396
|
-
// console.error(err.message);
|
|
397
|
-
// }
|
|
398
|
-
// }
|
|
399
|
-
// if (doc.type === "directory") {
|
|
400
|
-
// try {
|
|
401
|
-
// const sizeInBytes = await get_folder_size(
|
|
402
|
-
// req.path,
|
|
403
|
-
// drive_type,
|
|
404
|
-
// null,
|
|
405
|
-
// uid
|
|
406
|
-
// );
|
|
407
|
-
// files.sizeInBytes += sizeInBytes;
|
|
408
|
-
// files.children.push({
|
|
409
|
-
// sizeInBytes,
|
|
410
|
-
// size: formatBytes(sizeInBytes),
|
|
411
|
-
// name: doc.folder_name,
|
|
412
|
-
// path: "/" + doc._id,
|
|
413
|
-
// file_path: "/" + doc._id,
|
|
414
|
-
// date_created: doc.date_created,
|
|
415
|
-
// });
|
|
416
|
-
// } catch (err) {
|
|
417
|
-
// console.error(err.message);
|
|
418
|
-
// }
|
|
419
|
-
// }
|
|
420
|
-
// }
|
|
421
|
-
// files.size = formatBytes(files.size);
|
|
422
|
-
// return { code: 1, data: files };
|
|
276
|
+
|
|
423
277
|
return {
|
|
424
278
|
code: 1,
|
|
425
279
|
data: await get_drive_files(ret, file_doc, null, uid),
|