Merge pull request #20396 from peppy/files-folder-notice

Add warning message in `files` folder to avoid accidental deletion
This commit is contained in:
Dan Balasescu 2022-09-22 15:18:18 +09:00 committed by GitHub
commit 729322c505
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -5,6 +5,7 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Threading;
@ -255,6 +256,8 @@ namespace osu.Game
InitialiseFonts();
addFilesWarning();
Audio.Samples.PlaybackConcurrency = SAMPLE_CONCURRENCY;
dependencies.Cache(SkinManager = new SkinManager(Storage, realm, Host, Resources, Audio, Scheduler));
@ -373,6 +376,29 @@ namespace osu.Game
Beatmap.BindValueChanged(onBeatmapChanged);
}
private void addFilesWarning()
{
var realmStore = new RealmFileStore(realm, Storage);
const string filename = "IMPORTANT READ ME.txt";
if (!realmStore.Storage.Exists(filename))
{
using (var stream = realmStore.Storage.CreateFileSafely(filename))
using (var textWriter = new StreamWriter(stream))
{
textWriter.WriteLine(@"This folder contains all your user files (beatmaps, skins, replays etc.)");
textWriter.WriteLine(@"Please do not touch or delete this folder!!");
textWriter.WriteLine();
textWriter.WriteLine(@"If you are really looking to completely delete user data, please delete");
textWriter.WriteLine(@"the parent folder including all other files and directories");
textWriter.WriteLine();
textWriter.WriteLine(@"For more information on how these files are organised,");
textWriter.WriteLine(@"see https://github.com/ppy/osu/wiki/User-file-storage");
}
}
}
private void onTrackChanged(WorkingBeatmap beatmap, TrackChangeDirection direction)
{
// FramedBeatmapClock uses a decoupled clock internally which will mutate the source if it is an `IAdjustableClock`.