Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[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:
  1. Clone some repository using JGit.
  2. Add commits to the repository on the git server side (for example, push commits from another computer).
  3. Fetch the cloned repository using JGit.
  4. Call the JGit GC on the cloned repository.
  5. After the GC the cloned repository 'objects/pack' folder contains all packs -- both existed before the GC and created during the GC.
  6. 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.
It seems this is a bug.
The logic of the bug is the following:
  1. The JGit clone & fetch operations mark the created pack files as 'read-only' in the ObjectDirectoryPackParser.parse method:
  2. JGit GC operation also marks the created pack files as 'read-only' in the GC.writePack method:
  3. JGit uses Files.delete() method in the GC.removeOldPack to remove old pack files:
  4. This Files.delete() method unable to remove 'read-only' files on Windows (please see, throws an exception, but this exception is silently ignored:
  5. 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.

Best regards,
  Denis Malyshkin,
Senior Java Developer
of ISS Art, Ltd., Omsk, Russia.
Mobile Phone: +7 913 669 2896
Office tel/fax +7 3812 396959
Yahoo Messenger: dmalyshkin

E-mail: dmalyshkin@xxxxxxxxxx

Back to the top