diff options
author | Dariusz Luksza <dariusz.luksza@gmail.com> | 2023-11-20 11:00:51 +0000 |
---|---|---|
committer | Dariusz Luksza <dariusz.luksza@gmail.com> | 2024-01-29 09:33:36 +0000 |
commit | ca54c517647957685aa3401e097871aaebf250e3 (patch) | |
tree | 38702b3562dfab935f7a62ae440e71e033d952d5 /org.eclipse.jgit/src | |
parent | 60af389b49fe1d05753a4a2b9146d1b925c71e23 (diff) | |
download | jgit-ca54c517647957685aa3401e097871aaebf250e3.tar.gz jgit-ca54c517647957685aa3401e097871aaebf250e3.zip |
Fix handling of missing pack index file
As demonstrated in
`UploadPackHandleDeletedPackFile.testV2IdxFileRemovedDuringUploadPack`
the fetch operation will fail when the pack index file is removed.
This is due to a wrapping of `FileNotFoundException` (which is a
subclass of `IOExeption`) in an `IOException` at PackIndex L#68. This
is then changing the behaviour of error handling in
`Pack.file.getBitmapIndex()` where the `FileNotFoundException` is
swallowed and allows the fetch process to continue. With FNFE being
wrapped in IOE, this blows up and breaks the fetch operation.
Simply rethrowing `FileNotFoundException` from `PackFile.open()` fixes
the broken fetch operation. This will also mark the whole pack as
invalid in the `IOException` handler in `Pack.idx()` method.
Change-Id: Ibe321aa1af21d26500e1cb2eb3464cc99a6dbc62
Signed-off-by: Dariusz Luksza <dariusz.luksza@gmail.com>
(cherry picked from commit e0910eda3ea1c474b4cf9b00ac698f739a982f8c)
Diffstat (limited to 'org.eclipse.jgit/src')
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/Pack.java | 6 | ||||
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackIndex.java | 4 |
2 files changed, 6 insertions, 4 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/Pack.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/Pack.java index 6e74136c1b..29f936587d 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/Pack.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/Pack.java @@ -1129,9 +1129,9 @@ public class Pack implements Iterable<PackIndex.MutableEntry> { idx = PackBitmapIndex.open(bitmapIdxFile, idx(), getReverseIdx()); } catch (FileNotFoundException e) { - // Once upon a time this bitmap file existed. Now it - // has been removed. Most likely an external gc has - // removed this packfile and the bitmap + // Once upon a time the bitmap or index files existed. Now one + // of them has been removed. Most likely an external gc has + // removed index, packfile or the bitmap bitmapIdxFile = null; return null; } diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackIndex.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackIndex.java index f4f62d4205..c0689dc634 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackIndex.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackIndex.java @@ -64,7 +64,9 @@ public abstract class PackIndex public static PackIndex open(File idxFile) throws IOException { try (SilentFileInputStream fd = new SilentFileInputStream( idxFile)) { - return read(fd); + return read(fd); + } catch (FileNotFoundException e) { + throw e; } catch (IOException ioe) { throw new IOException( MessageFormat.format(JGitText.get().unreadablePackIndex, |