Example #1
0
 /// <summary>
 /// Releases all unmanaged and optionally managed resources.
 /// </summary>
 /// <param name="disposing">When true, managed resources are released.</param>
 protected override void Dispose(bool disposing)
 {
     if (this.disposed)
     {
         return;
     }
     if (disposing)
     {
         if (this.fsStream != null)
         {
             this.fsStream.Dispose();
         }
         else
         {
             try
             {
                 this.Flush();
                 if (this.fileAccess != CMS.IO.FileAccess.Read &&
                     this.fileMode != CMS.IO.FileMode.Open &&
                     this.fsTemp.CanWrite &&
                     !this.mMultiPartUploadMode)
                 {
                     this.fsTemp.Seek(0L, SeekOrigin.Begin);
                     this.Provider.PutDataFromStreamToObject(this.obj, this.fsTemp);
                     this.SetLastWriteTimeAndCreationTimeToS3Object();
                 }
             }
             catch (Exception ex)
             {
                 EventLogProvider.LogException("Custom Amazon", "STREAMDISPOSE", ex, 0);
             }
             finally
             {
                 this.fsTemp.Dispose();
                 if (this.mReadSize > 0)
                 {
                     FileDebug.LogReadEnd(this.mReadSize);
                     this.mReadSize = -1;
                 }
                 this.LogFileOperation(this.mPath, "Close", -1);
             }
         }
     }
     this.disposed = true;
     base.Dispose(disposing);
 }
Example #2
0
 /// <summary>Closes current stream.</summary>
 public override void Close()
 {
     if (this.fsStream != null)
     {
         this.fsStream.Close();
     }
     else
     {
         this.Dispose(true);
         this.fsTemp.Close();
     }
     if (this.mReadSize > 0)
     {
         FileDebug.LogReadEnd(this.mReadSize);
         this.mReadSize = -1;
     }
     this.LogFileOperation(this.mPath, nameof(Close), -1);
 }