add parts concurrency s3

This commit is contained in:
fyears 2022-03-14 23:42:18 +08:00
parent 1699d39f62
commit a2fb515b74
4 changed files with 30 additions and 1 deletions

View File

@ -12,6 +12,7 @@ export interface S3Config {
s3SecretAccessKey: string;
s3BucketName: string;
bypassCorsLocally?: boolean;
partsConcurrency?: number;
}
export interface DropboxConfig {

View File

@ -585,6 +585,9 @@ export default class RemotelySavePlugin extends Plugin {
if (this.settings.webdav.depth === undefined) {
this.settings.webdav.depth = "auto_unknown";
}
if (this.settings.s3.partsConcurrency === undefined) {
this.settings.s3.partsConcurrency = 20;
}
}
async saveSettings() {

View File

@ -154,6 +154,7 @@ export const DEFAULT_S3_CONFIG = {
s3SecretAccessKey: "",
s3BucketName: "",
bypassCorsLocally: true,
partsConcurrency: 20,
};
export type S3ObjectType = _Object;
@ -291,7 +292,7 @@ export const uploadToRemote = async (
const body = new Uint8Array(remoteContent);
const upload = new Upload({
client: s3Client,
queueSize: 20, // concurrency
queueSize: s3Config.partsConcurrency, // concurrency
partSize: bytesIn5MB, // minimal 5MB by default
leavePartsOnError: false,
params: {

View File

@ -754,6 +754,30 @@ export class RemotelySaveSettingTab extends PluginSettingTab {
});
}
const partsConcurrencyDiv = s3Div.createEl("div");
new Setting(partsConcurrencyDiv)
.setName("Parts Concurrency")
.setDesc(
"Large files are split into small parts to upload in S3. How many parts do you want to upload in parallel at most?"
)
.addDropdown((dropdown) => {
dropdown.addOption("1", "1");
dropdown.addOption("2", "2");
dropdown.addOption("3", "3");
dropdown.addOption("5", "5");
dropdown.addOption("10", "10");
dropdown.addOption("15", "15");
dropdown.addOption("20", "20 (default)");
dropdown
.setValue(`${this.plugin.settings.s3.partsConcurrency}`)
.onChange(async (val) => {
const realVal = parseInt(val);
this.plugin.settings.s3.partsConcurrency = realVal;
await this.plugin.saveSettings();
});
});
new Setting(s3Div)
.setName("check connectivity")
.setDesc("check connectivity")