diff --git a/src/Commands/QueryFileContent.cs b/src/Commands/QueryFileContent.cs index 2aec351b..f887859c 100644 --- a/src/Commands/QueryFileContent.cs +++ b/src/Commands/QueryFileContent.cs @@ -17,9 +17,9 @@ namespace SourceGit.Commands starter.WindowStyle = ProcessWindowStyle.Hidden; starter.RedirectStandardOutput = true; + var stream = new MemoryStream(); try { - var stream = new MemoryStream(); var proc = new Process() { StartInfo = starter }; proc.Start(); proc.StandardOutput.BaseStream.CopyTo(stream); @@ -27,13 +27,13 @@ namespace SourceGit.Commands proc.Close(); stream.Position = 0; - return stream; } catch (Exception e) { App.RaiseException(repo, $"Failed to query file content: {e}"); - return null; } + + return stream; } } } diff --git a/src/ViewModels/CommitDetail.cs b/src/ViewModels/CommitDetail.cs index ecd85ad3..fe719517 100644 --- a/src/ViewModels/CommitDetail.cs +++ b/src/ViewModels/CommitDetail.cs @@ -475,7 +475,7 @@ namespace SourceGit.ViewModels if (IMG_EXTS.Contains(ext)) { var stream = Commands.QueryFileContent.Run(_repo, _commit.SHA, file.Path); - var bitmap = stream != null ? new Bitmap(stream) : null as Bitmap; + var bitmap = stream.Length > 0 ? new Bitmap(stream) : null; Dispatcher.UIThread.Invoke(() => { ViewRevisionFileContent = new Models.RevisionImageFile() { Image = bitmap }; diff --git a/src/ViewModels/DiffContext.cs b/src/ViewModels/DiffContext.cs index deb1b014..728c4f43 100644 --- a/src/ViewModels/DiffContext.cs +++ b/src/ViewModels/DiffContext.cs @@ -166,7 +166,7 @@ namespace SourceGit.ViewModels private Bitmap BitmapFromRevisionFile(string repo, string revision, string file) { var stream = Commands.QueryFileContent.Run(repo, revision, file); - return stream != null ? new Bitmap(stream) : null; + return stream.Length > 0 ? new Bitmap(stream) : null; } private static readonly HashSet IMG_EXTS = new HashSet()