Skip to content

Commit 5b29f05

Browse files
authored
Fix to zip with absolute path for Auto File Scans instead relative path. (#4486)
1 parent 178f7e5 commit 5b29f05

File tree

1 file changed

+6
-3
lines changed
  • plugins/toolkit/jetbrains-core/src/software/aws/toolkits/jetbrains/services/codewhisperer/codescan/sessionconfig

1 file changed

+6
-3
lines changed

plugins/toolkit/jetbrains-core/src/software/aws/toolkits/jetbrains/services/codewhisperer/codescan/sessionconfig/CodeScanSessionConfig.kt

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ class CodeScanSessionConfig(
9696
}
9797

9898
// Copy all the included source files to the source zip
99-
val srcZip = zipFiles(payloadMetadata.sourceFiles.map { Path.of(it) })
99+
val srcZip = zipFiles(payloadMetadata.sourceFiles.map { Path.of(it) }, scope)
100100
val payloadContext = PayloadContext(
101101
payloadMetadata.language,
102102
payloadMetadata.linesScanned,
@@ -129,9 +129,12 @@ class CodeScanSessionConfig(
129129
return bufferedReader.useLines { lines -> lines.count() }
130130
}
131131

132-
private fun zipFiles(files: List<Path>): File = createTemporaryZipFile {
132+
private fun zipFiles(files: List<Path>, scope: CodeAnalysisScope): File = createTemporaryZipFile {
133133
files.forEach { file ->
134-
val relativePath = file.relativeTo(projectRoot.toNioPath())
134+
val relativePath = when (scope) {
135+
CodeAnalysisScope.PROJECT -> file.relativeTo(projectRoot.toNioPath())
136+
else -> file
137+
}
135138
LOG.debug { "Selected file for truncation: $file" }
136139
it.putNextEntry(relativePath.toString(), file)
137140
}

0 commit comments

Comments
 (0)