@xuda.io/drive_module 1.1.1213 → 1.1.1215
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 +27 -5
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -204,7 +204,7 @@ exports.get_drive_files = async function (req) {
|
|
|
204
204
|
sizeInBytes: 0,
|
|
205
205
|
children: [],
|
|
206
206
|
};
|
|
207
|
-
|
|
207
|
+
debugger;
|
|
208
208
|
for await (let doc of ret.docs) {
|
|
209
209
|
if (doc.type === 'file') {
|
|
210
210
|
let ts = '';
|
|
@@ -1113,20 +1113,42 @@ exports.upload_drive_file = async function (req, job_id, headers, file_obj) {
|
|
|
1113
1113
|
const check_existing_file_ret = await module.exports.check_drive_file(check_req);
|
|
1114
1114
|
|
|
1115
1115
|
if (check_existing_file_ret.code < 0) {
|
|
1116
|
+
// const rename_file_name = async function (i) {
|
|
1117
|
+
// if (i > 1000) {
|
|
1118
|
+
// return { code: -1, data: 'too many retries renaming existing file' };
|
|
1119
|
+
// }
|
|
1120
|
+
|
|
1121
|
+
// let tmp_originalname = originalname + ` (${i})`;
|
|
1122
|
+
|
|
1123
|
+
// // check_req.file_name = tmp_originalname;
|
|
1124
|
+
// check_req.file_path = path.join(doc.file_path, tmp_originalname);
|
|
1125
|
+
|
|
1126
|
+
// const re_check_res = await module.exports.check_drive_file(check_req);
|
|
1127
|
+
// if (re_check_res.code < 0) {
|
|
1128
|
+
// i++;
|
|
1129
|
+
// return await rename_file_name(i);
|
|
1130
|
+
// }
|
|
1131
|
+
// return { code: 1, data: tmp_originalname };
|
|
1132
|
+
// };
|
|
1133
|
+
|
|
1116
1134
|
const rename_file_name = async function (i) {
|
|
1117
1135
|
if (i > 1000) {
|
|
1118
1136
|
return { code: -1, data: 'too many retries renaming existing file' };
|
|
1119
1137
|
}
|
|
1120
1138
|
|
|
1121
|
-
|
|
1139
|
+
// Extract filename parts
|
|
1140
|
+
const parsed = path.parse(originalname);
|
|
1141
|
+
const baseName = parsed.name; // filename without extension
|
|
1142
|
+
const extension = parsed.ext; // .webp, .jpg, etc.
|
|
1143
|
+
|
|
1144
|
+
// Insert (i) before the extension
|
|
1145
|
+
let tmp_originalname = `${baseName} (${i})${extension}`;
|
|
1122
1146
|
|
|
1123
|
-
// check_req.file_name = tmp_originalname;
|
|
1124
1147
|
check_req.file_path = path.join(doc.file_path, tmp_originalname);
|
|
1125
1148
|
|
|
1126
1149
|
const re_check_res = await module.exports.check_drive_file(check_req);
|
|
1127
1150
|
if (re_check_res.code < 0) {
|
|
1128
|
-
i
|
|
1129
|
-
return await rename_file_name(i);
|
|
1151
|
+
return await rename_file_name(i + 1);
|
|
1130
1152
|
}
|
|
1131
1153
|
return { code: 1, data: tmp_originalname };
|
|
1132
1154
|
};
|