File tree Expand file tree Collapse file tree 2 files changed +25
-2
lines changed
amazonq/.changes/next-release
core/src/amazonqFeatureDev/util Expand file tree Collapse file tree 2 files changed +25
-2
lines changed Original file line number Diff line number Diff line change 1+ {
2+ "type" : " Bug Fix" ,
3+ "description" : " Amazon Q /dev: Fix issue when files are deleted while preparing context"
4+ }
Original file line number Diff line number Diff 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 ( )
You can’t perform that action at this time.
0 commit comments