1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 21:07:33 +08:00

Merge pull request #19563 from peppy/realm-migration-safety

Change migration logic to ignore realm pipe files regardless of database filename
This commit is contained in:
Salman Ahmed 2022-08-03 12:11:50 +03:00 committed by GitHub
commit dbdfa90012
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 25 additions and 3 deletions

View File

@ -26,6 +26,11 @@ namespace osu.Game.IO
/// </summary> /// </summary>
public virtual string[] IgnoreFiles => Array.Empty<string>(); public virtual string[] IgnoreFiles => Array.Empty<string>();
/// <summary>
/// A list of file/directory suffixes which should not be migrated.
/// </summary>
public virtual string[] IgnoreSuffixes => Array.Empty<string>();
protected MigratableStorage(Storage storage, string subPath = null) protected MigratableStorage(Storage storage, string subPath = null)
: base(storage, subPath) : base(storage, subPath)
{ {
@ -73,6 +78,9 @@ namespace osu.Game.IO
if (topLevelExcludes && IgnoreFiles.Contains(fi.Name)) if (topLevelExcludes && IgnoreFiles.Contains(fi.Name))
continue; continue;
if (IgnoreSuffixes.Any(suffix => fi.Name.EndsWith(suffix, StringComparison.Ordinal)))
continue;
allFilesDeleted &= AttemptOperation(() => fi.Delete(), throwOnFailure: false); allFilesDeleted &= AttemptOperation(() => fi.Delete(), throwOnFailure: false);
} }
@ -81,6 +89,9 @@ namespace osu.Game.IO
if (topLevelExcludes && IgnoreDirectories.Contains(dir.Name)) if (topLevelExcludes && IgnoreDirectories.Contains(dir.Name))
continue; continue;
if (IgnoreSuffixes.Any(suffix => dir.Name.EndsWith(suffix, StringComparison.Ordinal)))
continue;
allFilesDeleted &= AttemptOperation(() => dir.Delete(true), throwOnFailure: false); allFilesDeleted &= AttemptOperation(() => dir.Delete(true), throwOnFailure: false);
} }
@ -101,6 +112,9 @@ namespace osu.Game.IO
if (topLevelExcludes && IgnoreFiles.Contains(fileInfo.Name)) if (topLevelExcludes && IgnoreFiles.Contains(fileInfo.Name))
continue; continue;
if (IgnoreSuffixes.Any(suffix => fileInfo.Name.EndsWith(suffix, StringComparison.Ordinal)))
continue;
AttemptOperation(() => AttemptOperation(() =>
{ {
fileInfo.Refresh(); fileInfo.Refresh();
@ -119,6 +133,9 @@ namespace osu.Game.IO
if (topLevelExcludes && IgnoreDirectories.Contains(dir.Name)) if (topLevelExcludes && IgnoreDirectories.Contains(dir.Name))
continue; continue;
if (IgnoreSuffixes.Any(suffix => dir.Name.EndsWith(suffix, StringComparison.Ordinal)))
continue;
CopyRecursive(dir, destination.CreateSubdirectory(dir.Name), false); CopyRecursive(dir, destination.CreateSubdirectory(dir.Name), false);
} }
} }

View File

@ -38,15 +38,20 @@ namespace osu.Game.IO
public override string[] IgnoreDirectories => new[] public override string[] IgnoreDirectories => new[]
{ {
"cache", "cache",
$"{OsuGameBase.CLIENT_DATABASE_FILENAME}.management",
}; };
public override string[] IgnoreFiles => new[] public override string[] IgnoreFiles => new[]
{ {
"framework.ini", "framework.ini",
"storage.ini", "storage.ini",
$"{OsuGameBase.CLIENT_DATABASE_FILENAME}.note", };
$"{OsuGameBase.CLIENT_DATABASE_FILENAME}.lock",
public override string[] IgnoreSuffixes => new[]
{
// Realm pipe files don't play well with copy operations
".note",
".lock",
".management",
}; };
public OsuStorage(GameHost host, Storage defaultStorage) public OsuStorage(GameHost host, Storage defaultStorage)