Exemplo n.º 1
0
 public override void FlushBuffer(byte[] b, int offset, int len)
 {
     try
     {
         _indexOutputFilesSummary.Increment(len);
         if (_ms != null)
         {
             if (_ms.Capacity - _ms.Position - len >= 0)
             {
                 _ms.Write(b, offset, len);
                 return;
             }
             // too big, copy the buffer to the file
             _file = _fileCache.RentFileStream();
             var position = _ms.Position;
             _ms.Position = 0;
             _ms.CopyTo(_file);
             _file.Position = position;
             _fileCache.ReturnMemoryStream(_ms);
             _ms = null;
         }
         _file.Write(b, offset, len);
     }
     catch (IOException ioe) when(ioe.IsOutOfDiskSpaceException())
     {
         ThrowDiskFullException();
     }
 }
Exemplo n.º 2
0
        protected override void Dispose(bool disposing)
        {
            try
            {
                base.Dispose(disposing);

                CopyFileStream();
            }
            finally
            {
                if (_ms != null)
                {
                    _fileCache.ReturnMemoryStream(_ms);
                }
                _ms = null;
                if (_file != null)
                {
                    _fileCache.ReturnFileStream(_file);
                }
                _file = null;
            }
        }