Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 336800 - Cannot delete a directory after cloning a repository into it
Summary: Cannot delete a directory after cloning a repository into it
Status: CLOSED WORKSFORME
Alias: None
Product: JGit
Classification: Technology
Component: JGit (show other bugs)
Version: 0.11   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Philipp Thun CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 336227
  Show dependency tree
 
Reported: 2011-02-10 06:58 EST by Tomasz Zarna CLA
Modified: 2011-02-28 10:57 EST (History)
2 users (show)

See Also:


Attachments
failing tests (1.32 KB, patch)
2011-02-10 06:59 EST, Tomasz Zarna CLA
no flags Details | Diff
failing test with org.eclipse.jgit.util.FileUtils (1.47 KB, patch)
2011-02-10 10:48 EST, Tomasz Zarna CLA
no flags Details | Diff
mylyn/context/zip (6.50 KB, application/octet-stream)
2011-02-10 10:48 EST, Tomasz Zarna CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Tomasz Zarna CLA 2011-02-10 06:58:53 EST
In bug 336227 I'm trying to be a good citizen and clean up after running tests. The problem I found is that I'm not able to delete directories with clones as long as tests are running. This boils down to a pack file that cannot be removed.

I've modified org.eclipse.jgit.api.CloneCommandTest to illustrate the issue I'm dealing with. I'm not sure if this is something I should upload to Gerrit. This is not a real patch.
Comment 1 Tomasz Zarna CLA 2011-02-10 06:59:37 EST
Created attachment 188677 [details]
failing tests
Comment 2 Chris Aniszczyk CLA 2011-02-10 09:57:10 EST
In JGit, we wrote a FileUtils class to help with this...

FileUtils.delete(repo.getWorkTree(), FileUtils.RECURSIVE | FileUtils.RETRY);

org.eclipse.jgit.util.FileUtils

Try that first, if it doesn't work, then we can dig deeper.
Comment 3 Tomasz Zarna CLA 2011-02-10 10:48:34 EST
Created attachment 188693 [details]
failing test with org.eclipse.jgit.util.FileUtils

Thanks for the tip but it didn't help. I still get: "java.lang.AssertionError: Could not delete file C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\testCloneRepository3656357236185082524664761946001\.git\objects\pack\pack-5a1e97de671900849c0b7657ff9e866080544d28.pack [...]"
Comment 4 Tomasz Zarna CLA 2011-02-10 10:48:36 EST
Created attachment 188694 [details]
mylyn/context/zip
Comment 5 Philipp Thun CLA 2011-02-28 10:57:18 EST
You are creating a new Git object that has a repository associated with it. This repository is automatically opened and thus has to be closed so that file resources are released. By adding "git2.getRepository().close();" before "FileUtils.delete(...);", the repository gets closed, the pack file is released and removing the directory works.

I think contributing this enhanced test case would be a good idea.