/// <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> /// Default constructor /// </summary> /// <param name="backupName">The backup name to use to get the paths</param> /// <param name="backupDirectories">The backup directory infos</param> /// <param name="displayName">The game display name</param> public GameBackups_BackupInfo(string backupName, IEnumerable <GameBackups_Directory> backupDirectories, string displayName) { BackupName = backupName; AllBackupDirectories = backupDirectories.GroupBy(x => x.BackupVersion).ToDictionary(x => x.Key, x => x.ToArray()); // Get the latest backup version to create a backup from LatestAvailableBackupVersion = AllBackupDirectories.Select(x => x.Value.Select(y => y.BackupVersion)).SelectMany(x => x).Max(); BackupLocation = Services.Data.Backup_BackupLocation + AppViewModel.BackupFamily + (BackupName + $"-{LatestAvailableBackupVersion.ToString().PadLeft(2, '0')}"); CompressedBackupLocation = BackupLocation.FullPath + AppFilePaths.BackupCompressionExtension; GameDisplayName = displayName; }
/// <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"); } }