vcs: do not load file content to memory to copy file

EA-116778 - FTBE: FileUtil.loadFileBytes
This commit is contained in:
Aleksey Pivovarov
2018-02-26 16:33:58 +03:00
parent 2ac622e817
commit 3233802ea4
2 changed files with 9 additions and 5 deletions
@@ -36,9 +36,7 @@ import com.intellij.openapi.ui.Messages;
import com.intellij.openapi.util.Ref;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.vfs.CharsetToolkit;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.openapi.vfs.VirtualFileWithoutContent;
import com.intellij.openapi.vfs.*;
import com.intellij.util.ArrayUtil;
import com.intellij.util.LineSeparator;
import com.intellij.util.PathUtil;
@@ -363,7 +361,8 @@ public class ExternalDiffToolUtil {
@Override
public void apply() throws IOException {
myFile.setBinaryContent(FileUtil.loadFileBytes(myLocalFile));
FileUtil.copy(myLocalFile, VfsUtilCore.virtualToIoFile(myFile));
VfsUtil.markDirty(false, false, myFile);
}
}
@@ -22,6 +22,8 @@ import com.intellij.openapi.vcs.FilePath;
import com.intellij.openapi.vcs.changes.CommitContext;
import com.intellij.openapi.vcs.changes.shelf.ShelvedBinaryFile;
import com.intellij.openapi.vcs.changes.shelf.ShelvedBinaryFilePatch;
import com.intellij.openapi.vfs.VfsUtil;
import com.intellij.openapi.vfs.VfsUtilCore;
import com.intellij.openapi.vfs.VirtualFile;
import java.io.File;
@@ -43,7 +45,10 @@ public class ApplyBinaryShelvedFilePatch extends ApplyFilePatchBase<ShelvedBinar
fileToPatch.delete(this);
}
else {
fileToPatch.setBinaryContent(FileUtil.loadFileBytes(new File(shelvedBinaryFile.SHELVED_PATH)));
File fromFile = new File(shelvedBinaryFile.SHELVED_PATH);
File toFile = VfsUtilCore.virtualToIoFile(fileToPatch);
FileUtil.copy(fromFile, toFile);
VfsUtil.markDirty(false, false, fileToPatch);
}
return SUCCESS;
}