Exemple #1
0
        public override void close()
        {
            _fileMutex.WaitOne();
            try
            {
                string fileName = _name;

                // make sure it's all written out
                _indexOutput.flush();

                long originalLength = _indexOutput.length();
                _indexOutput.close();

                Stream blobStream = new StreamInput(CacheDirectory.openInput(fileName, IOContext.DEFAULT));

                try
                {
                    // push the blobStream up to the cloud
                    _blob.UploadFromStream(blobStream);

                    // set the metadata with the original index file properties
                    _blob.Metadata["CachedLength"] = originalLength.ToString(CultureInfo.InvariantCulture);
                    _blob.SetMetadata();

                    Debug.WriteLine("PUT {1} bytes to {0} in cloud", _name, blobStream.Length);
                }
                finally
                {
                    blobStream.Dispose();
                }

                // clean up
                _indexOutput = null;
                _blob        = null;
                GC.SuppressFinalize(this);
            }
            finally
            {
                _fileMutex.ReleaseMutex();
            }
        }