oicq-icalingua-plus-plus 1.24.13 → 1.24.16

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.
@@ -147,18 +147,20 @@ async function sendJsonMsg(target, json, group, sign) {
147
147
  * @returns {import("../ref").ProtocolResponse}
148
148
  */
149
149
  async function sendFile(user_id, file, filename, callback) {
150
- let filesize, filemd5, filesha, filestream
150
+ let filesize, filemd5, filesha, filestream, _10MMd5
151
151
  if (file instanceof Uint8Array) {
152
152
  if (!Buffer.isBuffer(file))
153
153
  file = Buffer.from(file)
154
154
  filesize = file.length
155
155
  filemd5 = md5(file), filesha = common.sha1(file)
156
+ _10MMd5 = md5(file.subarray(0, 10002432))
156
157
  filename = filename ? String(filename) : ("file" + filemd5.toString("hex"))
157
158
  filestream = Readable.from(file, { objectMode: false, highWaterMark: 524288 })
158
159
  } else {
159
160
  file = String(file)
160
161
  filesize = (await fs.promises.stat(file)).size
161
162
  ;[filemd5, filesha] = await common.fileHash(file)
163
+ _10MMd5 = await common.md5Stream(fs.createReadStream(file, { start: 0, end: 10002431 }))
162
164
  filename = filename ? String(filename) : path.basename(file)
163
165
  filestream = fs.createReadStream(file, { highWaterMark: 524288 })
164
166
  }
@@ -170,7 +172,7 @@ async function sendFile(user_id, file, filename, callback) {
170
172
  20: user_id,
171
173
  30: filesize,
172
174
  40: filename,
173
- 50: filemd5,
175
+ 50: _10MMd5,
174
176
  60: filesha,
175
177
  70: "/storage/emulated/0/Android/data/com.tencent.mobileqq/Tencent/QQfile_recv/" + filename,
176
178
  80: 0,
@@ -206,7 +208,7 @@ async function sendFile(user_id, file, filename, callback) {
206
208
  100: filesize,
207
209
  200: filemd5,
208
210
  300: filesha,
209
- 400: filemd5,
211
+ 400: _10MMd5,
210
212
  600: fid,
211
213
  700: rsp1700[220].toBuffer(),
212
214
  },
@@ -252,7 +254,7 @@ async function sendFile(user_id, file, filename, callback) {
252
254
  1: {
253
255
  1: 0,
254
256
  3: fid,
255
- 4: filemd5,
257
+ 4: _10MMd5,
256
258
  5: filename,
257
259
  6: filesize,
258
260
  9: 1,
@@ -302,6 +302,7 @@ async function _uploadPtt(target, buf) {
302
302
  6: buf.length,
303
303
  11: 1,
304
304
  18: fid,
305
+ 29: codec,
305
306
  30: Buffer.from([8, 0, 40, 0, 56, 0]),
306
307
  });
307
308
  }
package/lib/service.js CHANGED
@@ -169,7 +169,7 @@ function highwayHttpUpload(readable, obj) {
169
169
  let offset = 0, limit = 524288
170
170
  obj.ticket = this.storage.sig_session
171
171
 
172
- const tasks = new Set()
172
+ const bufs = new Set()
173
173
  const controller = new AbortController();
174
174
  require("events").setMaxListeners(233, controller.signal);
175
175
  let finished = 0
@@ -208,11 +208,20 @@ function highwayHttpUpload(readable, obj) {
208
208
  _.writeUInt32BE(head.length, 1)
209
209
  _.writeUInt32BE(chunk.length, 5)
210
210
  const buf = Buffer.concat([_, head, chunk, __])
211
- const task = new Promise((resolve, reject) => {
212
- axios.post(url, buf, {
211
+ bufs.add(buf)
212
+ }
213
+ offset += data.length
214
+ })
215
+
216
+ return new Promise((resolve, reject) => {
217
+ readable.on("err", reject)
218
+ .on("end", async() => {
219
+ let flag = false
220
+ for (const buf of bufs) {
221
+ if (flag) break
222
+ await axios.post(url, buf, {
213
223
  responseType: "arraybuffer",
214
224
  httpAgent: agent,
215
- //cancelToken: c.token,
216
225
  signal: controller.signal,
217
226
  headers: {
218
227
  "Content-Length": String(buf.length),
@@ -235,41 +244,28 @@ function highwayHttpUpload(readable, obj) {
235
244
  return
236
245
  }
237
246
  ++finished
238
- percentage = (finished / tasks.size * 100).toFixed(2)
247
+ percentage = (finished / bufs.size * 100).toFixed(2)
239
248
  this.logger.debug(`highway(http) chunk uploaded (${percentage}%)`)
240
249
  if (typeof obj.callback === "function" && percentage)
241
250
  obj.callback(percentage)
242
- if (finished < tasks.size && rsp[7]?.toBuffer().length > 0) {
251
+ if (finished < bufs.size && rsp[7]?.toBuffer().length > 0) {
243
252
  controller.abort()
253
+ flag = true
254
+ this.logger.debug(`highway(http) can quick upload`)
244
255
  this.logger.debug(`highway(http) chunk uploaded (100.00%)`)
245
256
  if (typeof obj.callback === "function")
246
257
  obj.callback("100.00")
247
258
  }
248
- if (finished >= tasks.size && !rsp[7]?.toBuffer().length)
259
+ if (finished >= bufs.size && !rsp[7]?.toBuffer().length)
249
260
  reject("文件校验未通过,上传失败")
250
- resolve(undefined)
251
261
  }).catch(err => {
252
262
  if (err instanceof axios.Cancel === false) {
253
263
  reject(err)
254
264
  }
255
- resolve(undefined)
265
+ flag = true
256
266
  })
257
- })
258
- tasks.add(task)
259
- }
260
- offset += data.length
261
- })
262
-
263
- return new Promise((resolve, reject) => {
264
- readable.on("err", reject)
265
- .on("end", () => {
266
- Promise.all(tasks).then(resolve).catch(err => {
267
- if (err instanceof axios.Cancel === false) {
268
- controller.abort()
269
- reject(err)
270
- }
271
- resolve(undefined)
272
- })
267
+ }
268
+ resolve(undefined)
273
269
  })
274
270
  })
275
271
  }
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "oicq-icalingua-plus-plus",
3
3
  "app_name": "oicq-icalingua-plus-plus",
4
- "version": "1.24.13",
5
- "app_version": "1.24.13",
6
- "upday": "2024/05/23",
4
+ "version": "1.24.16",
5
+ "app_version": "1.24.16",
6
+ "upday": "2024/05/26",
7
7
  "protocol_version": "v11",
8
8
  "description": "oicq(https://github.com/takayama-lily/oicq) v1 for Icalingua++",
9
9
  "main": "index.js",