namespace RemSound.App; /// /// The one-shot "an update just succeeded" marker that drives the "what's new" popup. The in-app /// updater () writes it into the install folder ONLY when a swap completes /// successfully — never on a failed/rolled-back update — and MainForm consumes it (shows About once, /// then deletes it) on the next launch. Because the signal is positive and written only on success, a /// failed update can't re-trigger what's-new, which the old version-compare flag could. /// /// Kept as a tiny seam (rather than inline file calls) so the consume contract is unit-testable: write /// it into a throwaway folder, assert Exists, Consume once (true), then Exists is false and a second /// Consume is false. See the SelfTest "what's-new marker" case. /// internal static class WhatsNewMarker { private static string PathFor(string baseDir) => Path.Combine(baseDir, RemSoundUpdater.WhatsNewMarkerName); /// True if the success marker is present in (the install folder). public static bool Exists(string baseDir) { try { return File.Exists(PathFor(baseDir)); } catch { return false; } } /// Write the marker into . Called by the updater on success only. public static void Write(string baseDir) { File.WriteAllText(PathFor(baseDir), "One-shot marker: RemSound finished a successful update. \"What's new\" shows once on the next\r\n" + "launch, then this file is deleted. Safe to delete.\r\n"); } /// Delete the marker if present, so what's-new shows exactly once. Returns true if a marker /// was there (and is now gone); a delete is reliable in a way the old best-effort config-save wasn't. public static bool Consume(string baseDir) { try { var path = PathFor(baseDir); if (!File.Exists(path)) return false; File.Delete(path); return true; } catch { return false; } } }