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