fix more bugs on webdav
This commit is contained in:
parent
53a1c32b43
commit
43cf95c417
@ -329,10 +329,11 @@ export const getRemoteMeta = async (
|
|||||||
remotePath: string
|
remotePath: string
|
||||||
) => {
|
) => {
|
||||||
await client.init();
|
await client.init();
|
||||||
// log.info(`remotePath = ${remotePath}`);
|
log.debug(`getRemoteMeta remotePath = ${remotePath}`);
|
||||||
const res = (await client.client.stat(remotePath, {
|
const res = (await client.client.stat(remotePath, {
|
||||||
details: false,
|
details: false,
|
||||||
})) as FileStat;
|
})) as FileStat;
|
||||||
|
log.debug(`getRemoteMeta res=${JSON.stringify(res)}`);
|
||||||
return fromWebdavItemToRemoteItem(res, client.remoteBaseDir);
|
return fromWebdavItemToRemoteItem(res, client.remoteBaseDir);
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -479,12 +480,11 @@ export const listAllFromRemote = async (client: WrappedWebdavClient) => {
|
|||||||
|
|
||||||
const downloadFromRemoteRaw = async (
|
const downloadFromRemoteRaw = async (
|
||||||
client: WrappedWebdavClient,
|
client: WrappedWebdavClient,
|
||||||
fileOrFolderPath: string
|
remotePath: string
|
||||||
) => {
|
) => {
|
||||||
await client.init();
|
await client.init();
|
||||||
const p = getWebdavPath(fileOrFolderPath, client.remoteBaseDir);
|
// log.info(`getWebdavPath=${remotePath}`);
|
||||||
// log.info(`getWebdavPath=${p}`);
|
const buff = (await client.client.getFileContents(remotePath)) as BufferLike;
|
||||||
const buff = (await client.client.getFileContents(p)) as BufferLike;
|
|
||||||
if (buff instanceof ArrayBuffer) {
|
if (buff instanceof ArrayBuffer) {
|
||||||
return buff;
|
return buff;
|
||||||
} else if (buff instanceof Buffer) {
|
} else if (buff instanceof Buffer) {
|
||||||
@ -574,7 +574,7 @@ export const checkConnectivity = async (
|
|||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
const err = "Error: the url should start with http(s):// but it does not!";
|
const err = "Error: the url should start with http(s):// but it does not!";
|
||||||
log.debug(err);
|
log.error(err);
|
||||||
if (callbackFunc !== undefined) {
|
if (callbackFunc !== undefined) {
|
||||||
callbackFunc(err);
|
callbackFunc(err);
|
||||||
}
|
}
|
||||||
@ -582,10 +582,10 @@ export const checkConnectivity = async (
|
|||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
await client.init();
|
await client.init();
|
||||||
const results = await getRemoteMeta(client, "/");
|
const results = await getRemoteMeta(client, `/${client.remoteBaseDir}`);
|
||||||
if (results === undefined) {
|
if (results === undefined) {
|
||||||
const err = "results is undefined";
|
const err = "results is undefined";
|
||||||
log.debug(err);
|
log.error(err);
|
||||||
if (callbackFunc !== undefined) {
|
if (callbackFunc !== undefined) {
|
||||||
callbackFunc(err);
|
callbackFunc(err);
|
||||||
}
|
}
|
||||||
@ -593,7 +593,7 @@ export const checkConnectivity = async (
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
log.debug(err);
|
log.error(err);
|
||||||
if (callbackFunc !== undefined) {
|
if (callbackFunc !== undefined) {
|
||||||
callbackFunc(err);
|
callbackFunc(err);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user