diff options
author | Matthias Sohn <matthias.sohn@sap.com> | 2013-03-27 09:09:04 -0400 |
---|---|---|
committer | Gerrit Code Review @ Eclipse.org <gerrit@eclipse.org> | 2013-03-27 09:09:04 -0400 |
commit | edd47d10b9e96bde1958b19d04feef3cc8bf00fc (patch) | |
tree | 512bf8f698bc2fc8a1363744db768da224483d18 | |
parent | b1d191a1550891f349896373ff428e59571e4885 (diff) | |
parent | edf0da9c6ee06dbf702b0b16aa75539a11b74814 (diff) | |
download | jgit-edd47d10b9e96bde1958b19d04feef3cc8bf00fc.tar.gz jgit-edd47d10b9e96bde1958b19d04feef3cc8bf00fc.zip |
Merge "File.renameTo behaves differently on Unix and Windows"
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCacheCheckout.java | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCacheCheckout.java b/org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCacheCheckout.java index dd9023fc77..6fb56ed1b7 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCacheCheckout.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCacheCheckout.java @@ -1126,16 +1126,12 @@ public class DirCacheCheckout { fs.setExecute(tmpFile, false); } } - if (!tmpFile.renameTo(f)) { - // tried to rename which failed. Let' delete the target file and try - // again - FileUtils.delete(f, FileUtils.EMPTY_DIRECTORIES_ONLY - | FileUtils.RECURSIVE); - if (!tmpFile.renameTo(f)) { - throw new IOException(MessageFormat.format( - JGitText.get().couldNotWriteFile, tmpFile.getPath(), - f.getPath())); - } + try { + FileUtils.rename(tmpFile, f); + } catch (IOException e) { + throw new IOException(MessageFormat.format( + JGitText.get().couldNotWriteFile, tmpFile.getPath(), + f.getPath())); } entry.setLastModified(f.lastModified()); if (opt.getAutoCRLF() != AutoCRLF.FALSE) |