Skip to content

Commit d8aff5e

Browse files
committed
fix(amazonq): Skip including deleted files for FeatureDev context.
1 parent 3d90772 commit d8aff5e

File tree

2 files changed

+25
-2
lines changed

2 files changed

+25
-2
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"type": "Bug Fix",
3+
"description": "Amazon Q /dev: Fix issue when files are deleted while preparing context"
4+
}

packages/core/src/amazonqFeatureDev/util/files.ts

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,16 @@ export async function prepareRepoData(
3939
const ignoredExtensionMap = new Map<string, number>()
4040

4141
for (const file of files) {
42-
const fileSize = (await fs.stat(file.fileUri)).size
42+
let fileSize
43+
try {
44+
fileSize = (await fs.stat(file.fileUri)).size
45+
} catch (error) {
46+
if (error instanceof Error && error.message.includes('ENOENT')) {
47+
// No-op: Skip if file does not exist
48+
continue
49+
}
50+
throw error
51+
}
4352
const isCodeFile_ = isCodeFile(file.relativeFilePath)
4453

4554
if (fileSize >= maxFileSizeBytes || !isCodeFile_) {
@@ -58,7 +67,17 @@ export async function prepareRepoData(
5867
totalBytes += fileSize
5968

6069
const zipFolderPath = path.dirname(file.zipFilePath)
61-
zip.addLocalFile(file.fileUri.fsPath, zipFolderPath)
70+
71+
try {
72+
zip.addLocalFile(file.fileUri.fsPath, zipFolderPath)
73+
} catch (error) {
74+
if (error instanceof Error && error.message.includes('File not found')) {
75+
// No-op: Skip if file was deleted or does not exist
76+
// Reference: https://github.com/cthackers/adm-zip/blob/1cd32f7e0ad3c540142a76609bb538a5cda2292f/adm-zip.js#L296-L321
77+
continue
78+
}
79+
throw error
80+
}
6281
}
6382

6483
const iterator = ignoredExtensionMap.entries()

0 commit comments

Comments
 (0)