This commit is contained in:
fyears 2022-03-12 21:35:59 +08:00
parent 2d9610cd92
commit 479d2a4fac
3 changed files with 30 additions and 14 deletions

View File

@ -26,13 +26,15 @@ export interface DropboxConfig {
}
export type WebdavAuthType = "digest" | "basic";
export type WebdavDepthType = "auto_unknown" | "auto_1" | "auto_infinity" | "manual_1" | "manual_infinity";
export interface WebdavConfig {
address: string;
username: string;
password: string;
authType: WebdavAuthType;
manualRecursive: boolean;
manualRecursive: boolean; // deprecated in 0.3.6, use depth
depth?: WebdavDepthType;
}
export interface OnedriveConfig {

View File

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

View File

@ -11,6 +11,7 @@ import {
API_VER_REQURL,
SUPPORTED_SERVICES_TYPE,
WebdavAuthType,
WebdavDepthType,
} from "./baseTypes";
import { exportVaultSyncPlansToFiles } from "./debugMode";
import { exportQrCodeUri } from "./importExport";
@ -1073,25 +1074,35 @@ export class RemotelySaveSettingTab extends PluginSettingTab {
});
new Setting(webdavDiv)
.setName("server supports infinity propfind or not")
.setName("depth header sent to servers")
.setDesc(
"The plugin needs to get all files and folders recursively using probfind. If your webdav server only supports depth='1' (such as NGINX), you need to adjust the setting here, then the plugin consumes more network requests, but better than not working."
"Webdav servers should be configured to allow requests with header Depth being '1' or 'infinity'. The plugin needs to know this info. If you are not sure what's this, choose \"auto\"."
)
.addDropdown((dropdown) => {
dropdown.addOption("infinity", "supports depth='infinity'");
dropdown.addOption("1", "only supports depth='1'");
dropdown.addOption("auto", "auto detect");
dropdown.addOption("manual_1", "only supports depth='1'");
dropdown.addOption("manual_infinity", "only supports depth='infinity'");
type Depth = "1" | "infinity";
let initVal = "auto";
const autoOptions: Set<WebdavDepthType> = new Set(["auto_unknown", "auto_1", "auto_infinity"]);
if (autoOptions.has(this.plugin.settings.webdav.depth)) {
initVal = "auto";
} else {
initVal = this.plugin.settings.webdav.depth || "auto";
}
type DepthOption = "auto" | "manual_1" | "manual_infinity"
dropdown
.setValue(
this.plugin.settings.webdav.manualRecursive === false
? "infinity"
: "1"
)
.onChange(async (val: Depth) => {
if (val === "1") {
.setValue( initVal)
.onChange(async (val: DepthOption) => {
if (val === "auto") {
this.plugin.settings.webdav.depth = "auto_unknown";
this.plugin.settings.webdav.manualRecursive = false;
} else if (val === "manual_1") {
this.plugin.settings.webdav.depth = "manual_1";
this.plugin.settings.webdav.manualRecursive = true;
} else if (val === "infinity") {
} else if (val === "manual_infinity") {
this.plugin.settings.webdav.depth = "manual_infinity";
this.plugin.settings.webdav.manualRecursive = false;
}
await this.plugin.saveSettings();