@@ -250,15 +250,7 @@ async function writeRemoteDirectory(path: string, fileInfo: FileInfo, fetch: any
250250
251251async function writeLocalFile ( resourcePath : string , fileInfo : FileInfo , options : CopyOptions ) : Promise < string | undefined > {
252252 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+
262254 let executeWrite = true
263255 if ( options . interactiveOverride || options . noOverride ) {
264256 if ( fs . existsSync ( resourcePath ) ) {
@@ -278,6 +270,17 @@ async function writeLocalFile(resourcePath: string, fileInfo: FileInfo, options:
278270 try {
279271 if ( ! fileInfo . loadFile ) throw new Error ( `Could not load file at location: ${ fileInfo . absolutePath } ` )
280272 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+
281284 if ( fileData . buffer ) {
282285 fs . writeFileSync ( resourcePath , fileData . buffer )
283286 } else if ( fileData . blob ) {
0 commit comments