Example #1
0
        private void Verify(BlobKey attKey, byte[] clearText)
        {
            var path = _store.RawPathForKey(attKey);
            var raw  = File.ReadAllBytes(path);

            if (_encrypt)
            {
                raw.Should().NotBeNull()
                .And.Match(x => x.Locate(clearText) == -1, "because encrypted contents should not contain cleartext");
            }
            else
            {
                raw.Should().NotBeNull()
                .And.Equal(clearText, "because the contents should serialize to disk correctly");
            }
        }
        /// <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.RawPathForKey(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;
        }