skip extra checking folders for webdav
This commit is contained in:
parent
580397fbf9
commit
e460c563af
@ -5,6 +5,8 @@ import {
|
|||||||
requestUrl,
|
requestUrl,
|
||||||
requireApiVersion,
|
requireApiVersion,
|
||||||
Platform,
|
Platform,
|
||||||
|
Notice,
|
||||||
|
RequestUrlResponse,
|
||||||
} from "obsidian";
|
} from "obsidian";
|
||||||
|
|
||||||
import { Queue } from "@fyears/tsqueue";
|
import { Queue } from "@fyears/tsqueue";
|
||||||
@ -116,7 +118,6 @@ if (requireApiVersion(API_VER_REQURL) && !Platform.isAndroidApp) {
|
|||||||
// return r;
|
// return r;
|
||||||
// });
|
// });
|
||||||
import { AuthType, BufferLike, createClient } from "webdav/web";
|
import { AuthType, BufferLike, createClient } from "webdav/web";
|
||||||
import { Plane } from "lucide";
|
|
||||||
export type { WebDAVClient } from "webdav/web";
|
export type { WebDAVClient } from "webdav/web";
|
||||||
|
|
||||||
export const DEFAULT_WEBDAV_CONFIG = {
|
export const DEFAULT_WEBDAV_CONFIG = {
|
||||||
@ -217,7 +218,7 @@ export class WrappedWebdavClient {
|
|||||||
this.vaultFolderExists = true;
|
this.vaultFolderExists = true;
|
||||||
} else {
|
} else {
|
||||||
log.info("remote vault folder not exists, creating");
|
log.info("remote vault folder not exists, creating");
|
||||||
await this.client.createDirectory(`/${this.vaultName}`);
|
await this.client.createDirectory(`/${this.vaultName}/`);
|
||||||
log.info("remote vault folder created!");
|
log.info("remote vault folder created!");
|
||||||
this.vaultFolderExists = true;
|
this.vaultFolderExists = true;
|
||||||
}
|
}
|
||||||
@ -227,7 +228,7 @@ export class WrappedWebdavClient {
|
|||||||
if (this.webdavConfig.depth === "auto_unknown") {
|
if (this.webdavConfig.depth === "auto_unknown") {
|
||||||
let testPassed = false;
|
let testPassed = false;
|
||||||
try {
|
try {
|
||||||
const res = await this.client.customRequest(`/${this.vaultName}`, {
|
const res = await this.client.customRequest(`/${this.vaultName}/`, {
|
||||||
method: "PROPFIND",
|
method: "PROPFIND",
|
||||||
headers: {
|
headers: {
|
||||||
Depth: "infinity",
|
Depth: "infinity",
|
||||||
@ -246,7 +247,7 @@ export class WrappedWebdavClient {
|
|||||||
}
|
}
|
||||||
if (!testPassed) {
|
if (!testPassed) {
|
||||||
try {
|
try {
|
||||||
const res = await this.client.customRequest(`/${this.vaultName}`, {
|
const res = await this.client.customRequest(`/${this.vaultName}/`, {
|
||||||
method: "PROPFIND",
|
method: "PROPFIND",
|
||||||
headers: {
|
headers: {
|
||||||
Depth: "1",
|
Depth: "1",
|
||||||
@ -328,7 +329,7 @@ export const uploadToRemote = async (
|
|||||||
if (password === "") {
|
if (password === "") {
|
||||||
// if not encrypted, mkdir a remote folder
|
// if not encrypted, mkdir a remote folder
|
||||||
await client.client.createDirectory(uploadFile, {
|
await client.client.createDirectory(uploadFile, {
|
||||||
recursive: true,
|
recursive: false, // the sync algo should guarantee no need to recursive
|
||||||
});
|
});
|
||||||
const res = await getRemoteMeta(client, uploadFile);
|
const res = await getRemoteMeta(client, uploadFile);
|
||||||
return res;
|
return res;
|
||||||
@ -360,11 +361,12 @@ export const uploadToRemote = async (
|
|||||||
if (password !== "") {
|
if (password !== "") {
|
||||||
remoteContent = await encryptArrayBuffer(localContent, password);
|
remoteContent = await encryptArrayBuffer(localContent, password);
|
||||||
}
|
}
|
||||||
// we need to create folders before uploading
|
// updated 20220326: the algorithm guarantee this
|
||||||
const dir = getPathFolder(uploadFile);
|
// // we need to create folders before uploading
|
||||||
if (dir !== "/" && dir !== "") {
|
// const dir = getPathFolder(uploadFile);
|
||||||
await client.client.createDirectory(dir, { recursive: true });
|
// if (dir !== "/" && dir !== "") {
|
||||||
}
|
// await client.client.createDirectory(dir, { recursive: false });
|
||||||
|
// }
|
||||||
await client.client.putFileContents(uploadFile, remoteContent, {
|
await client.client.putFileContents(uploadFile, remoteContent, {
|
||||||
overwrite: true,
|
overwrite: true,
|
||||||
onUploadProgress: (progress: any) => {
|
onUploadProgress: (progress: any) => {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user