@xuda.io/drive_module 1.1.897 → 1.1.898

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 +62 -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
  });
@@ -260,66 +259,66 @@ exports.get_drive_files = async function (req) {
260
259
 
261
260
  const ret = await db_module.find_app_couch_query(app_id, opt);
262
261
 
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
- };
262
+ // const file_doc = await db_module.get_app_couch_doc(
263
+ // app_id,
264
+ // path.basename(req.path) || "/"
265
+ // );
266
+ // // console.log(file_doc);
267
+
268
+ // let files = {
269
+ // path: req.path || "/",
270
+ // name: file_doc.data.folder_name || "/",
271
+ // file_path: req.path || "/",
272
+ // // size: 0,
273
+ // sizeInBytes: 0,
274
+ // children: [],
275
+ // };
277
276
 
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);
277
+ // for await (let doc of ret.docs) {
278
+ // if (doc.type === "file") {
279
+ // try {
280
+ // files.sizeInBytes += doc.size;
281
+ // files.children.push({
282
+ // name: doc.originalname,
283
+ // sizeInBytes: doc.size,
284
+ // size: formatBytes(doc.size),
285
+ // extension: doc?.file_ext?.substr(1),
286
+ // type: doc.type,
287
+ // access_link: `https://${process.env.XUDA_HOSTNAME}/workspace-drive/${app_id}/${doc._id}`, //?gtp_token=${gtp_token}
288
+ // is_archive: doc.is_archive,
289
+ // public: doc.public,
290
+ // path: doc.file_path, // "/" + doc._id,
291
+ // date_created: doc.date_created,
292
+ // file_path: path.join(doc.file_path, doc.originalname),
293
+ // });
294
+ // } catch (err) {
295
+ // console.error(err.message);
296
+ // }
297
+ // }
298
+ // if (doc.type === "directory") {
299
+ // try {
300
+ // const sizeInBytes = await get_folder_size(
301
+ // req.path,
302
+ // drive_type,
303
+ // app_id_reference
304
+ // );
305
+ // files.sizeInBytes += sizeInBytes;
306
+ // files.children.push({
307
+ // sizeInBytes,
308
+ // size: formatBytes(sizeInBytes),
309
+ // name: doc.folder_name,
310
+ // path: "/" + doc._id,
311
+ // file_path: "/" + doc._id,
312
+ // type: doc.type,
313
+ // is_folder: true,
314
+ // date_created: doc.date_created,
315
+ // });
316
+ // } catch (err) {
317
+ // console.error(err.message);
318
+ // }
319
+ // }
320
+ // }
321
+ // files.size = formatBytes(files.sizeInBytes);
323
322
 
324
323
  return { code: 1, data: await process_drive_data(ret, file_doc) };
325
324
  };
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.898",
4
4
  "description": "Xuda Drive Server Module",
5
5
  "main": "index.js",
6
6
  "dependencies": {