chunk webdav upload to 5 mb

This commit is contained in:
fyears 2024-05-19 18:10:32 +08:00
parent 0391c42999
commit 45578a01dd

View File

@ -563,10 +563,10 @@ export class FakeFsWebdav extends FakeFs {
console.debug(`finish creating folder`); console.debug(`finish creating folder`);
// upload by chunks // upload by chunks
const size_6mb = 6 * 1024 * 1024; const size_5mb = 5 * 1024 * 1024;
let tmpFileIdx = 1; // a number between 1 and 10000 let tmpFileIdx = 1; // a number between 1 and 10000
let startInclusive = 0; let startInclusive = 0;
let endInclusive = Math.min(size_6mb, content.byteLength); let endInclusive = Math.min(size_5mb, content.byteLength);
do { do {
const tmpFileName = `${tmpFileIdx}`.padStart(5, "0"); const tmpFileName = `${tmpFileIdx}`.padStart(5, "0");
const tmpFileNameWithFolder = `${tmpFolder}/${tmpFileName}`; const tmpFileNameWithFolder = `${tmpFolder}/${tmpFileName}`;
@ -584,8 +584,8 @@ export class FakeFsWebdav extends FakeFs {
} }
); );
tmpFileIdx += 1; tmpFileIdx += 1;
startInclusive = Math.min(startInclusive + size_6mb, content.byteLength); startInclusive = Math.min(startInclusive + size_5mb, content.byteLength);
endInclusive = Math.min(endInclusive + size_6mb, content.byteLength); endInclusive = Math.min(endInclusive + size_5mb, content.byteLength);
} while (startInclusive < content.byteLength); } while (startInclusive < content.byteLength);
console.debug(`finish upload all chunks`); console.debug(`finish upload all chunks`);
@ -663,9 +663,9 @@ export class FakeFsWebdav extends FakeFs {
await this._writeFileFromRootFull(key, new ArrayBuffer(0), mtime, ctime); await this._writeFileFromRootFull(key, new ArrayBuffer(0), mtime, ctime);
// then "update" by chunks // then "update" by chunks
const size_6mb = 6 * 1024 * 1024; const size_5mb = 5 * 1024 * 1024;
let startInclusive = 0; let startInclusive = 0;
let endInclusive = Math.min(size_6mb, content.byteLength); let endInclusive = Math.min(size_5mb, content.byteLength);
do { do {
await this.client.partialUpdateFileContents( await this.client.partialUpdateFileContents(
key, key,
@ -674,8 +674,8 @@ export class FakeFsWebdav extends FakeFs {
content.slice(startInclusive, endInclusive - 1) content.slice(startInclusive, endInclusive - 1)
); );
startInclusive = Math.min(startInclusive + size_6mb, content.byteLength); startInclusive = Math.min(startInclusive + size_5mb, content.byteLength);
endInclusive = Math.min(endInclusive + size_6mb, content.byteLength); endInclusive = Math.min(endInclusive + size_5mb, content.byteLength);
} while (startInclusive < content.byteLength); } while (startInclusive < content.byteLength);
// lastly return // lastly return