Esempio n. 1
0
        private static bool CheckIfSnapshotIsEncrypted(string filePath, TransactionOperationContext context)
        {
            using (var zip = ZipFile.Open(filePath, ZipArchiveMode.Read, System.Text.Encoding.UTF8))
            {
                foreach (var zipEntry in zip.Entries)
                {
                    if (string.Equals(zipEntry.FullName, RestoreSettings.SettingsFileName, StringComparison.OrdinalIgnoreCase))
                    {
                        using (var entryStream = zipEntry.Open())
                        {
                            var json = context.Read(entryStream, "read database settings");
                            json.BlittableValidation();

                            RestoreSettings restoreSettings = JsonDeserializationServer.RestoreSettings(json);
                            return(restoreSettings.DatabaseRecord.Encrypted);
                        }
                    }
                }
            }

            throw new InvalidOperationException("Can't find settings file in backup archive.");
        }