Merge "Fix checking out large files"
This commit is contained in:
commit
40c2f68382
|
@ -45,8 +45,6 @@
|
|||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.channels.FileChannel;
|
||||
import java.text.MessageFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
@ -59,7 +57,6 @@
|
|||
import org.eclipse.jgit.errors.IncorrectObjectTypeException;
|
||||
import org.eclipse.jgit.errors.IndexWriteException;
|
||||
import org.eclipse.jgit.errors.MissingObjectException;
|
||||
import org.eclipse.jgit.lib.Constants;
|
||||
import org.eclipse.jgit.lib.FileMode;
|
||||
import org.eclipse.jgit.lib.ObjectId;
|
||||
import org.eclipse.jgit.lib.ObjectLoader;
|
||||
|
@ -836,21 +833,11 @@ private boolean isModified(String path) throws CorruptObjectException, IOExcepti
|
|||
public static void checkoutEntry(final Repository repo, File f, DirCacheEntry entry,
|
||||
boolean config_filemode) throws IOException {
|
||||
ObjectLoader ol = repo.open(entry.getObjectId());
|
||||
if (ol == null)
|
||||
throw new MissingObjectException(entry.getObjectId(),
|
||||
Constants.TYPE_BLOB);
|
||||
|
||||
byte[] bytes = ol.getCachedBytes();
|
||||
|
||||
File parentDir = f.getParentFile();
|
||||
File tmpFile = File.createTempFile("._" + f.getName(), null, parentDir);
|
||||
FileChannel channel = new FileOutputStream(tmpFile).getChannel();
|
||||
ByteBuffer buffer = ByteBuffer.wrap(bytes);
|
||||
FileOutputStream channel = new FileOutputStream(tmpFile);
|
||||
try {
|
||||
int j = channel.write(buffer);
|
||||
if (j != bytes.length)
|
||||
throw new IOException(MessageFormat.format(
|
||||
JGitText.get().couldNotWriteFile, tmpFile));
|
||||
ol.copyTo(channel);
|
||||
} finally {
|
||||
channel.close();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue