mirror of https://github.com/ppy/osu
Introduce migrations for drawings
This commit is contained in:
parent
1d4d749b53
commit
c9dc17f3d8
|
@ -54,8 +54,21 @@ internal void Migrate()
|
||||||
{
|
{
|
||||||
Logger.Log("Migrating bracket to default tournament storage.");
|
Logger.Log("Migrating bracket to default tournament storage.");
|
||||||
var bracketFile = new System.IO.FileInfo(host.Storage.GetFullPath("bracket.json"));
|
var bracketFile = new System.IO.FileInfo(host.Storage.GetFullPath("bracket.json"));
|
||||||
attemptOperation(() => bracketFile.CopyTo(Path.Combine(destination.FullName, bracketFile.Name), true));
|
moveFile(bracketFile, destination);
|
||||||
bracketFile.Delete();
|
}
|
||||||
|
|
||||||
|
if (host.Storage.Exists("drawings.txt"))
|
||||||
|
{
|
||||||
|
Logger.Log("Migrating drawings to default tournament storage.");
|
||||||
|
var drawingsFile = new System.IO.FileInfo(host.Storage.GetFullPath("drawings.txt"));
|
||||||
|
moveFile(drawingsFile, destination);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (host.Storage.Exists("drawings_results.txt"))
|
||||||
|
{
|
||||||
|
Logger.Log("Migrating drawings results to default tournament storage.");
|
||||||
|
var drawingsResultsFile = new System.IO.FileInfo(host.Storage.GetFullPath("drawings_results.txt"));
|
||||||
|
moveFile(drawingsResultsFile, destination);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (source.Exists)
|
if (source.Exists)
|
||||||
|
@ -97,6 +110,12 @@ private void deleteRecursive(DirectoryInfo target)
|
||||||
attemptOperation(target.Delete);
|
attemptOperation(target.Delete);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void moveFile(System.IO.FileInfo file, DirectoryInfo destination)
|
||||||
|
{
|
||||||
|
attemptOperation(() => file.CopyTo(Path.Combine(destination.FullName, file.Name), true));
|
||||||
|
file.Delete();
|
||||||
|
}
|
||||||
|
|
||||||
private void attemptOperation(Action action, int attempts = 10)
|
private void attemptOperation(Action action, int attempts = 10)
|
||||||
{
|
{
|
||||||
while (true)
|
while (true)
|
||||||
|
|
Loading…
Reference in New Issue