|Re: [jgit-dev] JGit GC unable to remove old pack files on Windows|
We found an issue with the JGit GC on Windows.
I've attached a simple example to expose this issue. Steps to reproduce:
It seems this is a bug.
- Clone some repository using JGit.
- Add commits to the repository on the git server side (for example, push commits from another computer).
- Fetch the cloned repository using JGit.
- Call the JGit GC on the cloned repository.
- After the GC the cloned repository 'objects/pack' folder contains all packs -- both existed before the GC and created during the GC.
- If you repeat steps 2-4 then new pack files appears on every iteration. And all old pack files remain in the repository 'objects/pack' folder.
The logic of the bug is the following:
- The JGit clone & fetch operations mark the created pack files as 'read-only' in the ObjectDirectoryPackParser.parse method:
- JGit GC operation also marks the created pack files as 'read-only' in the GC.writePack method:
- JGit uses Files.delete() method in the GC.removeOldPack to remove old pack files:
- This Files.delete() method unable to remove 'read-only' files on Windows (please see https://stackoverflow.com/questions/12139482/difference-between-filesdeletepath-and-filedelete), throws an exception, but this exception is silently ignored:
- As a result all pack files remain in the repository, but nobody knows that something goes wrong:It seems that the R/O attribute should be cleared before deleting old pack files.
Back to the top