@@ -250,15 +250,7 @@ async function writeRemoteDirectory(path: string, fileInfo: FileInfo, fetch: any
250
250
251
251
async function writeLocalFile ( resourcePath : string , fileInfo : FileInfo , options : CopyOptions ) : Promise < string | undefined > {
252
252
ensureDirectoryExistence ( resourcePath ) ;
253
- let ext = path . extname ( resourcePath )
254
- // Hardcode missing common extensions
255
- if ( resourcePath . endsWith ( '.acl' ) ) ext = '.acl'
256
- if ( resourcePath . endsWith ( '.meta' ) ) ext = '.meta'
257
- if ( ! ext ) {
258
- const extension = mime . extension ( fileInfo . contentType )
259
- if ( extension ) resourcePath = `${ resourcePath } $.${ extension } `
260
- }
261
-
253
+
262
254
let executeWrite = true
263
255
if ( options . interactiveOverride || options . noOverride ) {
264
256
if ( fs . existsSync ( resourcePath ) ) {
@@ -278,6 +270,17 @@ async function writeLocalFile(resourcePath: string, fileInfo: FileInfo, options:
278
270
try {
279
271
if ( ! fileInfo . loadFile ) throw new Error ( `Could not load file at location: ${ fileInfo . absolutePath } ` )
280
272
let fileData = await fileInfo . loadFile ( ) ;
273
+
274
+ // Handle writing data with the correct extension if no extension in the resource path
275
+ let ext = path . extname ( resourcePath )
276
+ // Hardcode missing common extensions
277
+ if ( resourcePath . endsWith ( '.acl' ) ) ext = '.acl'
278
+ if ( resourcePath . endsWith ( '.meta' ) ) ext = '.meta'
279
+ if ( ! ext ) {
280
+ const extension = mime . extension ( fileData . contentType )
281
+ if ( extension ) resourcePath = `${ resourcePath } $.${ extension } `
282
+ }
283
+
281
284
if ( fileData . buffer ) {
282
285
fs . writeFileSync ( resourcePath , fileData . buffer )
283
286
} else if ( fileData . blob ) {
0 commit comments