mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 10:12:54 +08:00
Add retry logic for realm backup creation
This commit is contained in:
parent
079b2dfc42
commit
7aad2780b1
@ -367,9 +367,24 @@ namespace osu.Game.Database
|
||||
using (BlockAllOperations())
|
||||
{
|
||||
Logger.Log($"Creating full realm database backup at {backupFilename}", LoggingTarget.Database);
|
||||
using (var source = storage.GetStream(Filename))
|
||||
using (var destination = storage.GetStream(backupFilename, FileAccess.Write, FileMode.CreateNew))
|
||||
source.CopyTo(destination);
|
||||
|
||||
int attempts = 10;
|
||||
|
||||
while (attempts-- > 0)
|
||||
{
|
||||
try
|
||||
{
|
||||
using (var source = storage.GetStream(Filename))
|
||||
using (var destination = storage.GetStream(backupFilename, FileAccess.Write, FileMode.CreateNew))
|
||||
source.CopyTo(destination);
|
||||
return;
|
||||
}
|
||||
catch (IOException)
|
||||
{
|
||||
// file may be locked during use.
|
||||
Thread.Sleep(500);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user