Permalink
Browse files

Added defensive temporary file removal even if caller not called Disp…

…ose()
  • Loading branch information...
1 parent 0a223be commit 9362bdf099d354785a018ca0e2931caefa5ff26d @ivan-danilov ivan-danilov committed Aug 6, 2011
Showing with 3 additions and 1 deletion.
  1. +3 −1 GitTfs/Util/TemporaryFileStream.cs
@@ -29,8 +29,9 @@ public string Filename
protected override void Dispose(bool disposing)
{
base.Dispose(disposing);
- if (!disposing || _filename == null) return;
+ if (_filename == null) return;
+ // doing the same both on disposing and finalizing
try
{
File.Delete(_filename);
@@ -46,6 +47,7 @@ protected override void Dispose(bool disposing)
Trace.WriteLine("Unable to delete temp file - unauthorized access: " + e);
// ignore!
}
+ // other exceptions indicate bugs so shouldn't be catched
}
}
}

0 comments on commit 9362bdf

Please sign in to comment.