@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.
- package/index.js +62 -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
|
});
|
|
@@ -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
|
-
|
|
265
|
-
|
|
266
|
-
);
|
|
267
|
-
// console.log(file_doc);
|
|
268
|
-
|
|
269
|
-
let files = {
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
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
|
-
|
|
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);
|
|
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
|
};
|