@xuda.io/drive_module 1.1.1017 → 1.1.1019
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 +2 -147
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -220,6 +220,7 @@ exports.get_drive_files = async function (req) {
|
|
|
220
220
|
path: doc.file_path,
|
|
221
221
|
date_created: doc.date_created,
|
|
222
222
|
file_path: path.join(doc.file_path, doc.originalname),
|
|
223
|
+
tags: doc.tags,
|
|
223
224
|
});
|
|
224
225
|
} catch (err) {
|
|
225
226
|
console.error(err.message);
|
|
@@ -258,83 +259,12 @@ exports.get_drive_files = async function (req) {
|
|
|
258
259
|
const app_id_reference = await _common.get_project_app_id(app_id);
|
|
259
260
|
opt.selector.docType = "workspace_drive";
|
|
260
261
|
|
|
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
262
|
const ret = await db_module.find_app_couch_query(app_id, opt);
|
|
277
263
|
|
|
278
264
|
const file_doc = await db_module.get_app_couch_doc(
|
|
279
265
|
app_id,
|
|
280
266
|
path.basename(req.path) || "/"
|
|
281
267
|
);
|
|
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
268
|
|
|
339
269
|
return {
|
|
340
270
|
code: 1,
|
|
@@ -344,82 +274,7 @@ exports.get_drive_files = async function (req) {
|
|
|
344
274
|
const get_user_files = async function () {
|
|
345
275
|
opt.selector.docType = "user_drive";
|
|
346
276
|
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 };
|
|
277
|
+
|
|
423
278
|
return {
|
|
424
279
|
code: 1,
|
|
425
280
|
data: await get_drive_files(ret, file_doc, null, uid),
|