/// <summary> /// Returns a <see cref="BeatmapSetInfo"/> to a usable state if it has previously been deleted but not yet purged. /// Is a no-op for already usable beatmaps. /// </summary> /// <param name="beatmapSet">The beatmap to restore.</param> public void Undelete(BeatmapSetInfo beatmapSet) { if (!beatmaps.Undelete(beatmapSet)) { return; } if (!beatmapSet.Protected) { files.Reference(beatmapSet.Files.Select(f => f.FileInfo).ToArray()); } }
/// <summary> /// Returns a <see cref="BeatmapSetInfo"/> to a usable state if it has previously been deleted but not yet purged. /// Is a no-op for already usable beatmaps. /// </summary> /// <param name="beatmaps">The store to restore beatmaps from.</param> /// <param name="files">The store to restore beatmap files from.</param> /// <param name="beatmapSet">The beatmap to restore.</param> private void undelete(BeatmapStore beatmaps, FileStore files, BeatmapSetInfo beatmapSet) { if (!beatmaps.Undelete(beatmapSet)) { return; } if (!beatmapSet.Protected) { files.Reference(beatmapSet.Files.Select(f => f.FileInfo).ToArray()); } }
/// <summary> /// Restore a beatmap that was previously deleted. Is a no-op if the beatmap is not in a deleted state, or has its protected flag set. /// </summary> /// <param name="beatmapSet">The beatmap to restore</param> public void Undelete(BeatmapSetInfo beatmapSet) { if (beatmapSet.Protected) { return; } using (var usage = contextFactory.GetForWrite()) { usage.Context.ChangeTracker.AutoDetectChangesEnabled = false; if (!beatmaps.Undelete(beatmapSet)) { return; } if (!beatmapSet.Protected) { files.Reference(beatmapSet.Files.Select(f => f.FileInfo).ToArray()); } usage.Context.ChangeTracker.AutoDetectChangesEnabled = true; } }