|
|
@ -53,6 +53,7 @@ import java.io.IOException; |
|
|
|
import java.io.OutputStream; |
|
|
|
import java.io.OutputStream; |
|
|
|
import java.nio.channels.Channels; |
|
|
|
import java.nio.channels.Channels; |
|
|
|
import java.nio.channels.FileChannel; |
|
|
|
import java.nio.channels.FileChannel; |
|
|
|
|
|
|
|
import java.nio.file.StandardCopyOption; |
|
|
|
import java.text.MessageFormat; |
|
|
|
import java.text.MessageFormat; |
|
|
|
import java.text.ParseException; |
|
|
|
import java.text.ParseException; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.ArrayList; |
|
|
@ -789,39 +790,33 @@ public class GC { |
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
tmpPack.setReadOnly(); |
|
|
|
tmpPack.setReadOnly(); |
|
|
|
boolean delete = true; |
|
|
|
|
|
|
|
try { |
|
|
|
FileUtils.rename(tmpPack, realPack, StandardCopyOption.ATOMIC_MOVE); |
|
|
|
FileUtils.rename(tmpPack, realPack); |
|
|
|
|
|
|
|
delete = false; |
|
|
|
|
|
|
|
for (Map.Entry<PackExt, File> tmpEntry : tmpExts.entrySet()) { |
|
|
|
for (Map.Entry<PackExt, File> tmpEntry : tmpExts.entrySet()) { |
|
|
|
File tmpExt = tmpEntry.getValue(); |
|
|
|
File tmpExt = tmpEntry.getValue(); |
|
|
|
tmpExt.setReadOnly(); |
|
|
|
tmpExt.setReadOnly(); |
|
|
|
|
|
|
|
|
|
|
|
File realExt = nameFor( |
|
|
|
File realExt = nameFor(id, |
|
|
|
id, "." + tmpEntry.getKey().getExtension()); //$NON-NLS-1$
|
|
|
|
"." + tmpEntry.getKey().getExtension()); //$NON-NLS-1$
|
|
|
|
try { |
|
|
|
try { |
|
|
|
FileUtils.rename(tmpExt, realExt); |
|
|
|
FileUtils.rename(tmpExt, realExt, |
|
|
|
|
|
|
|
StandardCopyOption.ATOMIC_MOVE); |
|
|
|
} catch (IOException e) { |
|
|
|
} catch (IOException e) { |
|
|
|
File newExt = new File(realExt.getParentFile(), |
|
|
|
File newExt = new File(realExt.getParentFile(), |
|
|
|
realExt.getName() + ".new"); //$NON-NLS-1$
|
|
|
|
realExt.getName() + ".new"); //$NON-NLS-1$
|
|
|
|
if (!tmpExt.renameTo(newExt)) |
|
|
|
try { |
|
|
|
|
|
|
|
FileUtils.rename(tmpExt, newExt, |
|
|
|
|
|
|
|
StandardCopyOption.ATOMIC_MOVE); |
|
|
|
|
|
|
|
} catch (IOException e2) { |
|
|
|
newExt = tmpExt; |
|
|
|
newExt = tmpExt; |
|
|
|
|
|
|
|
e = e2; |
|
|
|
|
|
|
|
} |
|
|
|
throw new IOException(MessageFormat.format( |
|
|
|
throw new IOException(MessageFormat.format( |
|
|
|
JGitText.get().panicCantRenameIndexFile, newExt, |
|
|
|
JGitText.get().panicCantRenameIndexFile, newExt, |
|
|
|
realExt)); |
|
|
|
realExt), e); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} finally { |
|
|
|
|
|
|
|
if (delete) { |
|
|
|
|
|
|
|
if (tmpPack.exists()) |
|
|
|
|
|
|
|
tmpPack.delete(); |
|
|
|
|
|
|
|
for (File tmpExt : tmpExts.values()) { |
|
|
|
|
|
|
|
if (tmpExt.exists()) |
|
|
|
|
|
|
|
tmpExt.delete(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return repo.getObjectDatabase().openPack(realPack); |
|
|
|
return repo.getObjectDatabase().openPack(realPack); |
|
|
|
} finally { |
|
|
|
} finally { |
|
|
|
if (tmpPack != null && tmpPack.exists()) |
|
|
|
if (tmpPack != null && tmpPack.exists()) |
|
|
|