Skip to content

Commit f350ba4

Browse files
committed
Fix: Fixed bug where copying files without extension from a pod to the local file system gave error
1 parent b04514d commit f350ba4

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

src/commands/solid-copy.ts

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -250,15 +250,7 @@ async function writeRemoteDirectory(path: string, fileInfo: FileInfo, fetch: any
250250

251251
async 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

Comments
 (0)