sc68cal/git-tfs — comment on commit 8a42a420aedbe904a6f0978c8eecaef090b1d4b8
File: GitTfs/Core/GitRepository.cs line 408
By sc68cal:

Perhaps something like this?

```
diff --git a/GitTfs/Core/GitRepository.cs b/GitTfs/Core/GitRepository.cs
index 94a4500..98a9171 100644
--- a/GitTfs/Core/GitRepository.cs
+++ b/GitTfs/Core/GitRepository.cs
@@ -404,16 +404,26 @@ namespace Sep.Git.Tfs.Core
using(LibGit2Sharp.Repository repo = new LibGit2Sharp.Repository(GitDir))
{
Blob blob;
- if ((blob = repo.Lookup(sha)) != null)
- Copy(blob.ContentStream, outputFile);
+ if ((blob = repo.Lookup(sha)) != null
+ && Copy(blob.ContentStream, outputFile))
+ blob.ContentStream.Close();
}
}

- private void Copy(Stream gitstream, string file)
+ private bool Copy(Stream gitstream, string file)
{
using (var destination = File.Create(file))
{
- gitstream.CopyTo(destination);
+ try
+ {
+ gitstream.CopyTo(destination);
+ return true;
+ }
+ catch (Exception ex)
+ {
+ Trace.WriteLine(ex.ToString());
+ return false;
+ }
}
}
```