Compare commits

...

5 Commits

Author SHA1 Message Date
f806027542 update description 2024-05-29 14:17:12 +02:00
ac68467806 1.1.2 2024-04-22 18:57:40 +02:00
b0152e1fe4 fix(core): update 2024-04-22 18:57:39 +02:00
825167af68 1.1.1 2024-04-22 17:58:28 +02:00
ba559e4304 fix(core): update 2024-04-22 17:58:27 +02:00
3 changed files with 27 additions and 6 deletions

View File

@ -1,6 +1,6 @@
{
"name": "@push.rocks/smartwebdav",
"version": "1.1.0",
"version": "1.1.2",
"private": false,
"description": "A TypeScript library for easy interaction with WebDAV servers, including file and directory management.",
"main": "dist_ts/index.js",
@ -29,12 +29,12 @@
},
"repository": {
"type": "git",
"url": "git+https://code.foss.global/push.rocks/smartwebdav.git"
"url": "https://code.foss.global/push.rocks/smartwebdav.git"
},
"bugs": {
"url": "https://code.foss.global/push.rocks/smartwebdav/issues"
},
"homepage": "https://code.foss.global/push.rocks/smartwebdav#readme",
"homepage": "https://code.foss.global/push.rocks/smartwebdav",
"browserslist": [
"last 1 chrome versions"
],
@ -62,4 +62,4 @@
"authentication",
"secure file transfer"
]
}
}

View File

@ -3,6 +3,6 @@
*/
export const commitinfo = {
name: '@push.rocks/smartwebdav',
version: '1.1.0',
version: '1.1.2',
description: 'A TypeScript library for easy interaction with WebDAV servers, including file and directory management.'
}

View File

@ -1,3 +1,4 @@
import type { isFile } from '@push.rocks/smartpath/dist_ts/smartpath.check.js';
import * as plugins from './plugins.js';
export interface IWebdavClientOptions {
@ -112,7 +113,27 @@ export class WebdavClient {
await this.wdClient.moveFile(sourcePathArg, targetPathArg);
}
public async deleteDirectory(pathArg: string) {
public async deleteFile(pathArg: string, checkNotDirectory = true) {
if (!(await this.wdClient.exists(pathArg))) {
throw new Error(`Path does not exist`);
}
if (checkNotDirectory && (await this.isDirecory(pathArg))) {
throw new Error(`Path is a directory, not a file`);
}
await this.wdClient.deleteFile(pathArg);
}
public async deleteDirectory(pathArg: string) {
await this.deleteFile(pathArg, false);
}
public async isFile(pathArg: string) {
const stat = (await this.wdClient.stat(pathArg)) as plugins.webdav.FileStat;
return stat.type === 'file';
}
public async isDirecory(pathArg: string) {
const stat = (await this.wdClient.stat(pathArg)) as plugins.webdav.FileStat;
return stat.type === 'directory';
}
}