From ba559e43049c61c9a74bfb6fa7a430c6d00a5849 Mon Sep 17 00:00:00 2001 From: Philipp Kunz Date: Mon, 22 Apr 2024 17:58:27 +0200 Subject: [PATCH] fix(core): update --- ts/00_commitinfo_data.ts | 2 +- ts/classes.webdavclient.ts | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/ts/00_commitinfo_data.ts b/ts/00_commitinfo_data.ts index 6917764..8f70096 100644 --- a/ts/00_commitinfo_data.ts +++ b/ts/00_commitinfo_data.ts @@ -3,6 +3,6 @@ */ export const commitinfo = { name: '@push.rocks/smartwebdav', - version: '1.1.0', + version: '1.1.1', description: 'A TypeScript library for easy interaction with WebDAV servers, including file and directory management.' } diff --git a/ts/classes.webdavclient.ts b/ts/classes.webdavclient.ts index 7cd0fa6..fed05c4 100644 --- a/ts/classes.webdavclient.ts +++ b/ts/classes.webdavclient.ts @@ -112,7 +112,15 @@ export class WebdavClient { await this.wdClient.moveFile(sourcePathArg, targetPathArg); } - public async deleteDirectory(pathArg: string) { + public async deleteFile(pathArg: string, checkNotDirectory = true) { + const stat = (await this.wdClient.stat(pathArg)) as plugins.webdav.FileStat; + if (checkNotDirectory && stat.type === 'directory') { + throw new Error(`Cannot delete a directory using deleteFile method. Use deleteDirectory instead.`); + } await this.wdClient.deleteFile(pathArg); } + + public async deleteDirectory(pathArg: string) { + await this.deleteFile(pathArg, false); + } }