File tree 2 files changed +12
-0
lines changed
2 files changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -118,6 +118,12 @@ export default class FtpStore {
118
118
const readableStream = this . #createReadableStream( content ) ;
119
119
const absolutePath = this . #absolutePath( filePath ) ;
120
120
121
+ // Return if file already exists
122
+ const fileExists = await client . exists ( absolutePath ) ;
123
+ if ( fileExists ) {
124
+ return ;
125
+ }
126
+
121
127
// Create directory if doesn’t exist
122
128
const directory = path . dirname ( absolutePath ) ;
123
129
const directoryType = await client . exists ( directory ) ;
Original file line number Diff line number Diff line change @@ -75,6 +75,12 @@ describe("store-ftp", () => {
75
75
) ;
76
76
} ) ;
77
77
78
+ it ( "Doesn’t create file if already exists" , async ( ) => {
79
+ await ftp . createFile ( "foo.md" , "foobar" ) ;
80
+
81
+ assert . equal ( await ftp . createFile ( "foo.md" , "foobar" ) , undefined ) ;
82
+ } ) ;
83
+
78
84
it ( "Throws error creating file" , async ( ) => {
79
85
await assert . rejects ( ftp . createFile ( undefined , "" ) , {
80
86
message : `FTP store: The "path" argument must be of type string. Received undefined` ,
You can’t perform that action at this time.
0 commit comments