Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use temporary storage for file exports on iOS #31039

Merged
merged 4 commits into from
Dec 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion osu.Game/Database/LegacyExporter.cs
Original file line number Diff line number Diff line change
@@ -9,6 +9,7 @@
using System.Threading.Tasks;
using osu.Framework.Platform;
using osu.Game.Extensions;
using osu.Game.IO;
using osu.Game.Overlays.Notifications;
using osu.Game.Utils;
using Realms;
@@ -46,7 +47,7 @@ public abstract class LegacyExporter<TModel>

protected LegacyExporter(Storage storage)
{
exportStorage = storage.GetStorageForDirectory(@"exports");
exportStorage = (storage as OsuStorage)?.GetExportStorage() ?? storage.GetStorageForDirectory(@"exports");
UserFileStorage = storage.GetStorageForDirectory(@"files");
}

5 changes: 5 additions & 0 deletions osu.Game/IO/OsuStorage.cs
Original file line number Diff line number Diff line change
@@ -61,6 +61,11 @@ public OsuStorage(GameHost host, Storage defaultStorage)
TryChangeToCustomStorage(out Error);
}

/// <summary>
/// Returns the <see cref="Storage"/> used for storing exported files.
/// </summary>
public virtual Storage GetExportStorage() => GetStorageForDirectory(@"exports");

/// <summary>
/// Resets the custom storage path, changing the target storage to the default location.
/// </summary>
4 changes: 4 additions & 0 deletions osu.iOS/OsuGameIOS.cs
Original file line number Diff line number Diff line change
@@ -5,6 +5,8 @@
using Foundation;
using Microsoft.Maui.Devices;
using osu.Framework.Graphics;
using osu.Framework.iOS;
using osu.Framework.Platform;
using osu.Game;
using osu.Game.Updater;
using osu.Game.Utils;
@@ -19,6 +21,8 @@ public partial class OsuGameIOS : OsuGame

protected override BatteryInfo CreateBatteryInfo() => new IOSBatteryInfo();

protected override Storage CreateStorage(GameHost host, Storage defaultStorage) => new OsuStorageIOS((IOSGameHost)host, defaultStorage);

protected override Edges SafeAreaOverrideEdges =>
// iOS shows a home indicator at the bottom, and adds a safe area to account for this.
// Because we have the home indicator (mostly) hidden we don't really care about drawing in this region.
23 changes: 23 additions & 0 deletions osu.iOS/OsuStorageIOS.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.

using System.IO;
using osu.Framework.iOS;
using osu.Framework.Platform;
using osu.Game.IO;

namespace osu.iOS
{
public class OsuStorageIOS : OsuStorage
{
private readonly IOSGameHost host;

public OsuStorageIOS(IOSGameHost host, Storage defaultStorage)
: base(host, defaultStorage)
{
this.host = host;
}

public override Storage GetExportStorage() => new IOSStorage(Path.GetTempPath(), host);
}
}
Loading