]> source.dussan.org Git - jgit.git/commitdiff
Let LockFile.unlock use FileUtils.delete() 82/2982/2
authorChristian Halstrick <christian.halstrick@sap.com>
Wed, 30 Mar 2011 15:29:10 +0000 (17:29 +0200)
committerChristian Halstrick <christian.halstrick@sap.com>
Sat, 2 Apr 2011 00:20:58 +0000 (02:20 +0200)
We sometimes face the problem that the file .git/index.lock
can't deleted causing JGit operations to fail. Problem is
that LockFile.unlock() simply deletes the lockfile and ignores the
return value of File.delete(). Instead use
FileUtils.delete() with retry option. This method will retry the
deletion of the file at most 10 times with sleeps inbetween.

Bug: 335959
Change-Id: I9598edea9f2304fe12e6f470301211b503434848
Signed-off-by: Christian Halstrick <christian.halstrick@sap.com>
org.eclipse.jgit/src/org/eclipse/jgit/storage/file/LockFile.java

index 6acd7132ad9ce9fad3038747cb455842d917e462..08dfd7e19bb342167da21eaa6f77a897db7febd8 100644 (file)
@@ -488,7 +488,11 @@ public class LockFile {
 
                if (haveLck) {
                        haveLck = false;
-                       lck.delete();
+                       try {
+                               FileUtils.delete(lck, FileUtils.RETRY);
+                       } catch (IOException e) {
+                               // couldn't delete the file even after retry.
+                       }
                }
        }