Open arysin opened 2 weeks ago
The (ugly) workaround like this removes the error message:
ObjectDatabase objectDatabase = git.getRepository().getObjectDatabase();
Object packed = FieldUtils.getDeclaredField(ObjectDirectory.class, "packed", true).get(objectDatabase);
AtomicReference packList = (AtomicReference) FieldUtils.getDeclaredField(packed.getClass(), "packList", true).get(packed);
Object packList_ = packList.get();
Pack[] packs = (Pack[]) FieldUtils.getDeclaredField(packList_.getClass(), "packs", true).get(packList_);
for(Pack pack: packs) {
RandomAccessFile fd = (RandomAccessFile) FieldUtils.getDeclaredField(pack.getClass(), "fd", true).get(pack);
fd.close();
}
Version
6.7.0
Operating System
Windows
Bug description
I clone a repository (with try/resouce on Git object) and after it's closed the git directory can't be deleted on Windows
Actual behavior
I get a message "C:\Users\user\AppData\Local\Temp\jgitRepository14654396429264831000.git\objects\pack\pack-065d80f75516484c8e0c0a3631b7cdf620f27328.pack: The process cannot access the file because it is being used by another process" I tried to force close but it does not help and the message states the repo is already closed:
close() called when useCnt is already zero for Repository
Expected behavior
The pack file should be released on repository.close() and .git directory should be deleted
Relevant log output
Other information
No response