Compare commits
	
		
			4 Commits
		
	
	
		
			v1.1.0
			...
			ac68467806
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| ac68467806 | |||
| b0152e1fe4 | |||
| 825167af68 | |||
| ba559e4304 | 
@@ -1,6 +1,6 @@
 | 
				
			|||||||
{
 | 
					{
 | 
				
			||||||
  "name": "@push.rocks/smartwebdav",
 | 
					  "name": "@push.rocks/smartwebdav",
 | 
				
			||||||
  "version": "1.1.0",
 | 
					  "version": "1.1.2",
 | 
				
			||||||
  "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",
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -3,6 +3,6 @@
 | 
				
			|||||||
 */
 | 
					 */
 | 
				
			||||||
export const commitinfo = {
 | 
					export const commitinfo = {
 | 
				
			||||||
  name: '@push.rocks/smartwebdav',
 | 
					  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.'
 | 
					  description: 'A TypeScript library for easy interaction with WebDAV servers, including file and directory management.'
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,3 +1,4 @@
 | 
				
			|||||||
 | 
					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 {
 | 
				
			||||||
@@ -112,7 +113,27 @@ export class WebdavClient {
 | 
				
			|||||||
    await this.wdClient.moveFile(sourcePathArg, targetPathArg);
 | 
					    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);
 | 
					    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';
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user