GithubHelp home page GithubHelp logo

Ngit File locks about ngit HOT 12 OPEN

mono avatar mono commented on June 25, 2024
Ngit File locks

from ngit.

Comments (12)

alanmcgovern avatar alanmcgovern commented on June 25, 2024

What version of ngit are you using? Is it the very latest commit in master?

from ngit.

dougrathbone avatar dougrathbone commented on June 25, 2024

Yes i've pulled from here on my recent builds and the problem is definitely there.. If I do a simple clone, and then try and recursively delete the folder i've cloned into a few seconds later (even 10 second later) the files are locked.

from ngit.

dougrathbone avatar dougrathbone commented on June 25, 2024

Any update to this? I still can't delete the cloned directory within a short timespan

from ngit.

dougrathbone avatar dougrathbone commented on June 25, 2024

Try this:

var repoPath = "C:\\otherrepopath";
var checkoutDir = "C:\\output"; 

var cmd = Git.CloneRepository();
cmd.SetDirectory(checkoutDir);
cmd.SetURI(repoPath);
var git = cmd.Call();
git.Checkout().SetName("master").Call();

Directory.Delete(checkoutDir,true);

am I missing something? the IDX will be locked.

calling GetRespository().Close() doesn't appear help.

from ngit.

dougrathbone avatar dougrathbone commented on June 25, 2024

This is also mentioned in a number of jGit posts:

http://dev.eclipse.org/mhonarc/lists/jgit-dev/msg01951.html

http://dev.eclipse.org/mhonarc/lists/jgit-dev/msg01954.html

I've tested by even ReposityCache.Close(repo) until the useCnt drops to -1 and the file is still locked.

This seems to be a breaking issue with NGit.

from ngit.

Therzok avatar Therzok commented on June 25, 2024

Yeah. JGit is broken in that regard. I haven't managed to find a high level fix, so that means we're stuck with waiting for the JGit team to fix it.

from ngit.

Therzok avatar Therzok commented on June 25, 2024

Could you try forcing a few GC collections? Try doing it at least 3 times.

from ngit.

dougrathbone avatar dougrathbone commented on June 25, 2024

Are there any hacks I can do to release the file handle?

from ngit.

Therzok avatar Therzok commented on June 25, 2024

I've tried setting FileAttributes to normal, but it didn't cut it.

from ngit.

dougrathbone avatar dougrathbone commented on June 25, 2024

Yeah I've also tried to recommended FileUtils.Delete(checkoutDir, FileUtils.RECURSIVE | FileUtils.RETRY); the jGit guys are using with no luck.

many rounds of GC.Collect do nothing. There is a stream or file handle left open. Am trying to open the solution locally to start debugging the lock, but don't have SharpZipLib,Mono.Posix or Mono.Security.

Where can I grab these?

from ngit.

dougrathbone avatar dougrathbone commented on June 25, 2024

I have found a way to clear all of the file handles. You need to really be specific about your releases.

original example:

var repoPath = "C:\\otherrepopath";
var checkoutDir = "C:\\output"; 

var cmd = Git.CloneRepository();
cmd.SetDirectory(checkoutDir);
cmd.SetURI(repoPath);
var git = cmd.Call();
git.Checkout().SetName("master").Call();

Directory.Delete(checkoutDir,true);

New version without file locks:

var repoPath = "C:\\otherrepopath";
var checkoutDir = "C:\\output"; 

var cmd = Git.CloneRepository();
cmd.SetDirectory(checkoutDir);
cmd.SetURI(repoPath);
var git = cmd.Call();
var gitCheckout = git.Checkout().SetName("master").Call(); //assign the return to capture the handle
gitCheckout.GetRepository().Close(); //release the handle
git.GetRepository().Close(); // release the first handle

Directory.Delete(checkoutDir,true);

from ngit.

dougrathbone avatar dougrathbone commented on June 25, 2024

I find that the fluent API makes it very easy to lose track of references and file handles made between fluent calls.

This seems to be a serious issue with Ngit that should be addressed whereby if being called through the fluent API, previous references should be closed in consecutive calls.

from ngit.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.