mirror of
https://github.com/ppy/osu.git
synced 2025-02-13 19:12:54 +08:00
Remove unnecessary parameters and implement delete
This commit is contained in:
parent
ce66b72390
commit
d2ae146c1f
@ -13,17 +13,6 @@ using osu.Game.Tournament.Configuration;
|
|||||||
|
|
||||||
namespace osu.Game.Tournament
|
namespace osu.Game.Tournament
|
||||||
{
|
{
|
||||||
internal class TournamentVideoStorage : NamespacedResourceStore<byte[]>
|
|
||||||
{
|
|
||||||
public TournamentVideoStorage(Storage storage)
|
|
||||||
: base(new StorageBackedResourceStore(storage), "videos")
|
|
||||||
{
|
|
||||||
AddExtension("m4v");
|
|
||||||
AddExtension("avi");
|
|
||||||
AddExtension("mp4");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
internal class TournamentStorage : WrappedStorage
|
internal class TournamentStorage : WrappedStorage
|
||||||
{
|
{
|
||||||
private readonly GameHost host;
|
private readonly GameHost host;
|
||||||
@ -72,9 +61,10 @@ namespace osu.Game.Tournament
|
|||||||
ChangeTargetStorage(UnderlyingStorage.GetStorageForDirectory(default_path));
|
ChangeTargetStorage(UnderlyingStorage.GetStorageForDirectory(default_path));
|
||||||
storageConfig.Set(StorageConfig.CurrentTournament, default_path);
|
storageConfig.Set(StorageConfig.CurrentTournament, default_path);
|
||||||
storageConfig.Save();
|
storageConfig.Save();
|
||||||
|
deleteRecursive(source);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void copyRecursive(DirectoryInfo source, DirectoryInfo destination, bool topLevelExcludes = true)
|
private void copyRecursive(DirectoryInfo source, DirectoryInfo destination)
|
||||||
{
|
{
|
||||||
// based off example code https://docs.microsoft.com/en-us/dotnet/api/system.io.directoryinfo
|
// based off example code https://docs.microsoft.com/en-us/dotnet/api/system.io.directoryinfo
|
||||||
|
|
||||||
@ -85,10 +75,26 @@ namespace osu.Game.Tournament
|
|||||||
|
|
||||||
foreach (DirectoryInfo dir in source.GetDirectories())
|
foreach (DirectoryInfo dir in source.GetDirectories())
|
||||||
{
|
{
|
||||||
copyRecursive(dir, destination.CreateSubdirectory(dir.Name), false);
|
copyRecursive(dir, destination.CreateSubdirectory(dir.Name));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void deleteRecursive(DirectoryInfo target)
|
||||||
|
{
|
||||||
|
foreach (System.IO.FileInfo fi in target.GetFiles())
|
||||||
|
{
|
||||||
|
attemptOperation(() => fi.Delete());
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (DirectoryInfo dir in target.GetDirectories())
|
||||||
|
{
|
||||||
|
attemptOperation(() => dir.Delete(true));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (target.GetFiles().Length == 0 && target.GetDirectories().Length == 0)
|
||||||
|
attemptOperation(target.Delete);
|
||||||
|
}
|
||||||
|
|
||||||
private void attemptOperation(Action action, int attempts = 10)
|
private void attemptOperation(Action action, int attempts = 10)
|
||||||
{
|
{
|
||||||
while (true)
|
while (true)
|
||||||
@ -108,4 +114,14 @@ namespace osu.Game.Tournament
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
internal class TournamentVideoStorage : NamespacedResourceStore<byte[]>
|
||||||
|
{
|
||||||
|
public TournamentVideoStorage(Storage storage)
|
||||||
|
: base(new StorageBackedResourceStore(storage), "videos")
|
||||||
|
{
|
||||||
|
AddExtension("m4v");
|
||||||
|
AddExtension("avi");
|
||||||
|
AddExtension("mp4");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user