mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[diff] Fix extension, don't treat empty file as text
* Add "." to the temp file suffix to produce the file extension. * Don't treat any empty file as text with stub content: let it have the same type as detected by extension. This will show "Image can't be loaded" warning, for an empty jpg file, for example, but it is expected behavior. This doesn't affect ADDED changes: they don't have before revision at all and don't create FileContent for them.
This commit is contained in:
@@ -82,12 +82,8 @@ public class FileContent extends DiffContent {
|
||||
}
|
||||
|
||||
public static FileContent createFromTempFile(Project project, String name, String ext, @NotNull byte[] content) throws IOException {
|
||||
final File tempFile;
|
||||
if (content.length == 0) {
|
||||
tempFile = FileUtil.createTempFile(name, "txt");
|
||||
FileUtil.writeToFile(tempFile, "Does not exist");
|
||||
} else {
|
||||
tempFile = FileUtil.createTempFile(name, ext);
|
||||
File tempFile = FileUtil.createTempFile(name, "." + ext);
|
||||
if (content.length != 0) {
|
||||
FileUtil.writeToFile(tempFile, content);
|
||||
}
|
||||
tempFile.deleteOnExit();
|
||||
|
||||
Reference in New Issue
Block a user