Compare commits
No commits in common. "master" and "v1.1.1" have entirely different histories.
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@push.rocks/smartwebdav",
|
"name": "@push.rocks/smartwebdav",
|
||||||
"version": "1.1.2",
|
"version": "1.1.1",
|
||||||
"private": false,
|
"private": false,
|
||||||
"description": "A TypeScript library for easy interaction with WebDAV servers, including file and directory management.",
|
"description": "A TypeScript library for easy interaction with WebDAV servers, including file and directory management.",
|
||||||
"main": "dist_ts/index.js",
|
"main": "dist_ts/index.js",
|
||||||
@ -29,12 +29,12 @@
|
|||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://code.foss.global/push.rocks/smartwebdav.git"
|
"url": "git+https://code.foss.global/push.rocks/smartwebdav.git"
|
||||||
},
|
},
|
||||||
"bugs": {
|
"bugs": {
|
||||||
"url": "https://code.foss.global/push.rocks/smartwebdav/issues"
|
"url": "https://code.foss.global/push.rocks/smartwebdav/issues"
|
||||||
},
|
},
|
||||||
"homepage": "https://code.foss.global/push.rocks/smartwebdav",
|
"homepage": "https://code.foss.global/push.rocks/smartwebdav#readme",
|
||||||
"browserslist": [
|
"browserslist": [
|
||||||
"last 1 chrome versions"
|
"last 1 chrome versions"
|
||||||
],
|
],
|
||||||
@ -62,4 +62,4 @@
|
|||||||
"authentication",
|
"authentication",
|
||||||
"secure file transfer"
|
"secure file transfer"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,6 @@
|
|||||||
*/
|
*/
|
||||||
export const commitinfo = {
|
export const commitinfo = {
|
||||||
name: '@push.rocks/smartwebdav',
|
name: '@push.rocks/smartwebdav',
|
||||||
version: '1.1.2',
|
version: '1.1.1',
|
||||||
description: 'A TypeScript library for easy interaction with WebDAV servers, including file and directory management.'
|
description: 'A TypeScript library for easy interaction with WebDAV servers, including file and directory management.'
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
import type { isFile } from '@push.rocks/smartpath/dist_ts/smartpath.check.js';
|
|
||||||
import * as plugins from './plugins.js';
|
import * as plugins from './plugins.js';
|
||||||
|
|
||||||
export interface IWebdavClientOptions {
|
export interface IWebdavClientOptions {
|
||||||
@ -114,11 +113,9 @@ export class WebdavClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public async deleteFile(pathArg: string, checkNotDirectory = true) {
|
public async deleteFile(pathArg: string, checkNotDirectory = true) {
|
||||||
if (!(await this.wdClient.exists(pathArg))) {
|
const stat = (await this.wdClient.stat(pathArg)) as plugins.webdav.FileStat;
|
||||||
throw new Error(`Path does not exist`);
|
if (checkNotDirectory && stat.type === 'directory') {
|
||||||
}
|
throw new Error(`Cannot delete a directory using deleteFile method. Use deleteDirectory instead.`);
|
||||||
if (checkNotDirectory && (await this.isDirecory(pathArg))) {
|
|
||||||
throw new Error(`Path is a directory, not a file`);
|
|
||||||
}
|
}
|
||||||
await this.wdClient.deleteFile(pathArg);
|
await this.wdClient.deleteFile(pathArg);
|
||||||
}
|
}
|
||||||
@ -126,14 +123,4 @@ export class WebdavClient {
|
|||||||
public async deleteDirectory(pathArg: string) {
|
public async deleteDirectory(pathArg: string) {
|
||||||
await this.deleteFile(pathArg, false);
|
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';
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user