From b98e04a38da2502dfbbdcd4856e1f7b512fb2a6e Mon Sep 17 00:00:00 2001 From: Anilcan KARA Date: Sat, 13 Jul 2024 10:23:38 +0300 Subject: [PATCH 1/2] fileExists method --- src/Client.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/Client.ts b/src/Client.ts index 3579c0d..80cefb1 100644 --- a/src/Client.ts +++ b/src/Client.ts @@ -372,6 +372,14 @@ export class Client { return this.send("RNTO " + validDest) } + /** + * Check a file if it exists or not + */ + async fileExists(path: string): Promise { + const validPath = await this.protectWhitespace(path) + return this.sendIgnoringError(`SIZE ${validPath}`); + } + /** * Remove a file from the current working directory. * From 98ae5725f60b531c8b45831607991a94df2d6e44 Mon Sep 17 00:00:00 2001 From: Anilcan KARA Date: Sat, 13 Jul 2024 10:24:19 +0300 Subject: [PATCH 2/2] fileExists return boolean --- src/Client.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Client.ts b/src/Client.ts index 80cefb1..44ec567 100644 --- a/src/Client.ts +++ b/src/Client.ts @@ -377,7 +377,7 @@ export class Client { */ async fileExists(path: string): Promise { const validPath = await this.protectWhitespace(path) - return this.sendIgnoringError(`SIZE ${validPath}`); + return !!this.sendIgnoringError(`SIZE ${validPath}`); } /**