Пример #1
0
        /// <summary>
        /// Refreshes the backup info
        /// </summary>
        /// <returns>The task</returns>
        public async Task RefreshAsync()
        {
            ExistingBackups = await GetExistingBackupsAsync();

            // Get the latest backup version to restore from
            LatestAvailableRestoreVersion = ExistingBackups.FirstOrDefault()?.BackupVersion ?? -1;

            BackupDirectories  = AllBackupDirectories.TryGetValue(LatestAvailableBackupVersion) ?? new BackupDir[0];
            RestoreDirectories = LatestAvailableRestoreVersion == -1 ? new BackupDir[0] : AllBackupDirectories.TryGetValue(LatestAvailableRestoreVersion) ?? new BackupDir[0];
        }
    /// <summary>
    /// Refreshes the backup info
    /// </summary>
    /// <returns>The task</returns>
    public async Task RefreshAsync(ProgramDataSource dataSource)
    {
        ExistingBackups = await GetExistingBackupsAsync();

        // Get the latest backup version to restore from
        LatestAvailableRestoreVersion = GetPrimaryBackup?.BackupVersion ?? -1;

        BackupDirectories = AllBackupDirectories.TryGetValue(LatestAvailableBackupVersion)?.
                            Select(x => x.GetBackupReadSearchPattern(dataSource)).
                            ToArray() ?? Array.Empty <BackupSearchPattern>();

        RestoreDirectories = LatestAvailableRestoreVersion == -1
            ? Array.Empty <BackupSearchPattern>()
            : AllBackupDirectories.TryGetValue(LatestAvailableRestoreVersion)?.
                             SelectMany(x => x.GetBackupWriteSearchPatterns(dataSource)).
                             ToArray() ?? Array.Empty <BackupSearchPattern>();

        if (BackupDirectories.GroupBy(x => x.ID).Any(x => x.Count() > 1))
        {
            throw new InvalidOperationException("Multiple backup directories can not use the same ID starting from version 13.0.0");
        }
    }