Skip to content

Commit 87aeb00

Browse files
committed
3.1.0
1 parent 162c86a commit 87aeb00

4 files changed

Lines changed: 33 additions & 9 deletions

File tree

app/app-uploader.js

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import fs from 'node:fs';
44
import path from 'node:path';
5+
import crypto from 'node:crypto';
56
import { fileURLToPath } from 'url';
67

78
import { request } from 'undici';
@@ -246,7 +247,7 @@ async function uploadDir(localDir, remoteDir){
246247
}
247248

248249
// const maxTasks = data.size <= 4 * Math.pow(1024, 3) ? 10 : 5;
249-
const upload_status = await uploadChunks(app, data, filePath, maxTasks);
250+
const upload_status = await uploadChunks(app, data, filePath);
250251
delete data.uploaded;
251252

252253
if(upload_status.ok){
@@ -263,11 +264,33 @@ async function uploadDir(localDir, remoteDir){
263264
remoteFsList.push({ server_filename: remoteFile, size: data.size });
264265

265266
console.log(':: Checking created file...');
267+
const rmeta = await app.getFileMeta([upload_info.path]);
268+
269+
// hash check
270+
271+
let hashmatch;
272+
if(data.hash.chunks.length > 1){
273+
const hashStr = JSON.stringify(data.hash.chunks);
274+
const tbServerHash = crypto.createHash('md5').update(hashStr).digest('hex');
275+
hashmatch = tbServerHash == upload_info.md5;
276+
}
277+
else{
278+
hashmatch = data.hash.file == upload_info.md5;
279+
}
280+
281+
const hashMatchMsg = hashmatch ? 'MATCH' : 'MISMATCH';
282+
const logHashMatch = hashmatch ? console.log : console.error;
283+
logHashMatch(':: HASH:', upload_info.md5, `(${hashMatchMsg})`);
284+
285+
// file size check
286+
266287
const fsizeMatchMsg = data.size == rmeta.info[0].size ? 'MATCH' : 'MISMATCH';
267288
const logFSize = data.size == rmeta.info[0].size ? console.log : console.error;
268289
logFSize(':: SIZE:', rmeta.info[0].size, `(${fsizeMatchMsg})`);
269290

270-
if(data.size != rmeta.info[0].size){
291+
// skip deleting tbtemp file...
292+
293+
if(data.size != rmeta.info[0].size || !hashmatch){
271294
continue;
272295
}
273296

app/module-argv.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ class Args {
2020
this.yargs.wrap(Math.min(120));
2121
this.yargs.usage('Usage: $0 [options]');
2222
this.yargs.version(false);
23+
this.yargs.help(false);
2324
// set options
2425
const yargsOpts = {};
2526
for(const a of reqArgs){

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "terabox-node",
33
"name_ext": "TeraBox node",
4-
"version": "3.0.8",
4+
"version": "3.1.0",
55
"type": "module",
66
"bin": {
77
"tb-check": "app/app-check.js",
@@ -25,7 +25,7 @@
2525
"dateformat": "^5.0.3",
2626
"filesize": "^10.1.6",
2727
"qrcode-terminal": "^0.12.0",
28-
"terabox-api": "^1.3.3",
28+
"terabox-api": "^1.3.4",
2929
"tough-cookie": "^5.1.2",
3030
"undici": "^7.10.0",
3131
"yaml": "^2.8.0",

pnpm-lock.yaml

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)