Skip to content

Commit 4a3cf9a

Browse files
paulirwinCopilot
andauthored
Apply suggestions from code review
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
1 parent 7d860b9 commit 4a3cf9a

3 files changed

Lines changed: 11 additions & 4 deletions

File tree

.github/workflows/Lucene-Net-Index-Compatibility.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ on:
3131
paths:
3232
# The compatibility harness itself
3333
- 'src/java/index-compat/**/*'
34-
- 'src/Lucene.Net.Tests/Index/TestJavaCompatibility.cs'
34+
- 'src/Lucene.Net.Tests/Support/Index/CompatDocs.cs'
35+
- 'src/Lucene.Net.Tests/Support/Index/TestJavaCompatibility.cs'
3536
# Production code whose on-disk format the harness validates
3637
- 'src/Lucene.Net/Codecs/**/*'
3738
- 'src/Lucene.Net/Index/**/*'

src/java/index-compat/run-compat.bat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,4 @@ GOTO endcommentblock
2727
:: -----------------------------------------------------------------------------------
2828
:endcommentblock
2929
where pwsh >nul 2>nul
30-
if %ERRORLEVEL% NEQ 0 (echo "PowerShell could not be found. Please install version 3 or higher.") else (pwsh -ExecutionPolicy bypass -Command "& '%~dpn0.ps1'" %*)
30+
if %ERRORLEVEL% NEQ 0 (echo "PowerShell could not be found. Please install version 3 or higher." & exit /b 1) else (pwsh -ExecutionPolicy bypass -Command "& '%~dpn0.ps1'" %*)

src/java/index-compat/src/main/java/org/apache/lucenenet/compat/GenerateIndex.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,14 @@ public static void main(String[] args) throws Exception {
6666
private static void write(Path indexPath, boolean useCompoundFile) throws Exception {
6767
File dirFile = indexPath.toFile();
6868
if (dirFile.exists()) {
69-
for (File f : dirFile.listFiles()) {
70-
f.delete();
69+
File[] files = dirFile.listFiles();
70+
if (files == null) {
71+
throw new IllegalStateException("Index path exists but is not a directory: " + dirFile.getAbsolutePath());
72+
}
73+
for (File f : files) {
74+
if (!f.delete()) {
75+
throw new IllegalStateException("Failed to delete existing file: " + f.getAbsolutePath());
76+
}
7177
}
7278
} else {
7379
Files.createDirectories(indexPath);

0 commit comments

Comments
 (0)