예제 #1
0
        public void TestBasicOperation()
        {
            var item = Encoding.UTF8.GetBytes("this is an item");
            var key  = new BlobKey();
            var key2 = new BlobKey();

            _store.StoreBlob(item, key);
            _store.StoreBlob(item, key2);
            key.Should().Be(key2, "because keys should be deterministic");

            var readItem = _store.BlobForKey(key);

            readItem.Should().Equal(item, "beacuse the contents of a key should be read back correctly from disk");
            Verify(key, item);

            var path = _store.PathForKey(key);

            _encrypt.Should().Be(path == null, "because only plaintext attachments should return a path");
        }
예제 #2
0
        /// <summary>Installs a finished blob into the store.</summary>
        /// <remarks>Installs a finished blob into the store.</remarks>
        public virtual void Install()
        {
            if (tempFile == null)
            {
                return;
            }
            // already installed
            // Move temp file to correct location in blob store:
            string   destPath     = store.PathForKey(blobKey);
            FilePath destPathFile = new FilePath(destPath);
            bool     result       = tempFile.RenameTo(destPathFile);

            // If the move fails, assume it means a file with the same name already exists; in that
            // case it must have the identical contents, so we're still OK.
            if (result == false)
            {
                Cancel();
            }
            tempFile = null;
        }
예제 #3
0
        /// <summary>Installs a finished blob into the store.</summary>
        public void Install()
        {
            if (tempFile == null)
            {
                // already installed
                return;
            }

            // Move temp file to correct location in blob store:
            string destPath = store.PathForKey(blobKey);

            try {
                File.Move(tempFile, destPath);
            } catch (Exception) {
                // If the move fails, assume it means a file with the same name already exists; in that
                // case it must have the identical contents, so we're still OK.
                Cancel();
            }

            tempFile = null;
        }