public FileSystemCasBlobWriter(FileSystemCasConnection connection) { if (connection == null) { throw new ArgumentNullException("connection"); } _connection = connection; _hash = connection._hashName == null ? new SHA1CryptoServiceProvider() : HashAlgorithm.Create(connection._hashName); if (_hash == null) { throw new Exception("Missing hash algorithm: " + connection._hashName); } string temp; do { Guid unique = Guid.NewGuid(); temp = Path.Combine(connection._path, TemporaryFileBase + unique); } while (File.Exists(temp)); _tempStream = new FileStream(temp, FileMode.Create, FileAccess.Write, FileShare.None); _tempFile = temp; }
protected override void Dispose(bool disposing) { if (_tempStream != null) { lock (this) { _tempStream.Dispose(); _tempStream = null; AttemptDelete(new FileInfo(_tempFile)); _tempFile = null; } } if (disposing) { if (_hash != null) { ((IDisposable)_hash).Dispose(); } _hash = null; _connection = null; } base.Dispose(disposing); }
protected override void Dispose(bool disposing) { if (_tempStream != null) lock (this) { _tempStream.Dispose(); _tempStream = null; AttemptDelete(new FileInfo(_tempFile)); _tempFile = null; } if (disposing) { if (_hash != null) ((IDisposable) _hash).Dispose(); _hash = null; _connection = null; } base.Dispose(disposing); }
public FileSystemCasBlobWriter(FileSystemCasConnection connection) { if (connection == null) throw new ArgumentNullException("connection"); _connection = connection; _hash = connection._hashName == null ? new SHA1CryptoServiceProvider() : HashAlgorithm.Create(connection._hashName); if (_hash == null) throw new Exception("Missing hash algorithm: " + connection._hashName); string temp; do { Guid unique = Guid.NewGuid(); temp = Path.Combine(connection._path, TemporaryFileBase + unique); } while (File.Exists(temp)); _tempStream = new FileStream(temp, FileMode.Create, FileAccess.Write, FileShare.None); _tempFile = temp; }