]> source.dussan.org Git - jgit.git/commitdiff
Fix adding files in a network share 33/2333/2
authorRobin Rosenberg <robin.rosenberg@dewire.com>
Tue, 25 Jan 2011 22:26:38 +0000 (23:26 +0100)
committerChris Aniszczyk <caniszczyk@gmail.com>
Wed, 26 Jan 2011 17:26:55 +0000 (11:26 -0600)
We cannot always rename read-only files on network shares,
so rename the temp file for a new loose object first, and
then set it as read-only.

Bug: 335388
Change-Id: Ie0350e032a97e0d09626d6143c5c692873a5f6a2
Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
org.eclipse.jgit/src/org/eclipse/jgit/storage/file/ObjectDirectory.java

index afad321cb42c45ef04525a29ba6344f7cdadd80c..ac48d2a4bc548ff66d3b2113ff4c66e855b1d365 100644 (file)
@@ -472,8 +472,6 @@ public class ObjectDirectory extends FileObjectDatabase {
                        return InsertLooseObjectResult.EXISTS_PACKED;
                }
 
-               tmp.setReadOnly();
-
                final File dst = fileFor(id);
                if (dst.exists()) {
                        // We want to be extra careful and avoid replacing an object
@@ -484,6 +482,7 @@ public class ObjectDirectory extends FileObjectDatabase {
                        return InsertLooseObjectResult.EXISTS_LOOSE;
                }
                if (tmp.renameTo(dst)) {
+                       tmp.setReadOnly();
                        unpackedObjectCache.add(id);
                        return InsertLooseObjectResult.INSERTED;
                }