aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.HLE/HOS/Services/Account
diff options
context:
space:
mode:
authorMary <1760003+Thog@users.noreply.github.com>2021-07-13 16:48:54 +0200
committerMary <1760003+Thog@users.noreply.github.com>2021-07-13 16:48:54 +0200
commit208ba1dde2b9a4d31446ace2bba8f0d641d2e300 (patch)
treec7478e7eb87061400bab37daf4f2f69cf387d9f2 /Ryujinx.HLE/HOS/Services/Account
parent997380d48cb3b74e2438cee7fc3b017d6b59b714 (diff)
Revert LibHac update
Users are facing save destruction on failing extra data update apparently
Diffstat (limited to 'Ryujinx.HLE/HOS/Services/Account')
-rw-r--r--Ryujinx.HLE/HOS/Services/Account/Acc/AccountManager.cs46
1 files changed, 27 insertions, 19 deletions
diff --git a/Ryujinx.HLE/HOS/Services/Account/Acc/AccountManager.cs b/Ryujinx.HLE/HOS/Services/Account/Acc/AccountManager.cs
index 454ed1f3..2cea57e9 100644
--- a/Ryujinx.HLE/HOS/Services/Account/Acc/AccountManager.cs
+++ b/Ryujinx.HLE/HOS/Services/Account/Acc/AccountManager.cs
@@ -2,9 +2,12 @@
using LibHac.Fs;
using LibHac.Fs.Shim;
using Ryujinx.Common;
+using Ryujinx.HLE.FileSystem;
+using Ryujinx.HLE.FileSystem.Content;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
+using System.IO;
using System.Linq;
namespace Ryujinx.HLE.HOS.Services.Account.Acc
@@ -13,20 +16,16 @@ namespace Ryujinx.HLE.HOS.Services.Account.Acc
{
public static readonly UserId DefaultUserId = new UserId("00000000000000010000000000000000");
+ private readonly VirtualFileSystem _virtualFileSystem;
private readonly AccountSaveDataManager _accountSaveDataManager;
- // Todo: The account service doesn't have the permissions to delete save data. Qlaunch takes care of deleting
- // save data, so we're currently passing a client with full permissions. Consider moving save data deletion
- // outside of the AccountManager.
- private readonly HorizonClient _horizonClient;
-
private ConcurrentDictionary<string, UserProfile> _profiles;
public UserProfile LastOpenedUser { get; private set; }
- public AccountManager(HorizonClient horizonClient)
+ public AccountManager(VirtualFileSystem virtualFileSystem)
{
- _horizonClient = horizonClient;
+ _virtualFileSystem = virtualFileSystem;
_profiles = new ConcurrentDictionary<string, UserProfile>();
@@ -170,22 +169,31 @@ namespace Ryujinx.HLE.HOS.Services.Account.Acc
SaveDataFilter saveDataFilter = new SaveDataFilter();
saveDataFilter.SetUserId(new LibHac.Fs.UserId((ulong)userId.High, (ulong)userId.Low));
- _horizonClient.Fs.OpenSaveDataIterator(out SaveDataIterator saveDataIterator, SaveDataSpaceId.User, in saveDataFilter).ThrowIfFailure();
-
- Span<SaveDataInfo> saveDataInfo = stackalloc SaveDataInfo[10];
-
- while (true)
+ Result result = _virtualFileSystem.FsClient.OpenSaveDataIterator(out SaveDataIterator saveDataIterator, SaveDataSpaceId.User, ref saveDataFilter);
+ if (result.IsSuccess())
{
- saveDataIterator.ReadSaveDataInfo(out long readCount, saveDataInfo).ThrowIfFailure();
+ Span<SaveDataInfo> saveDataInfo = stackalloc SaveDataInfo[10];
- if (readCount == 0)
+ while (true)
{
- break;
- }
+ saveDataIterator.ReadSaveDataInfo(out long readCount, saveDataInfo);
- for (int i = 0; i < readCount; i++)
- {
- _horizonClient.Fs.DeleteSaveData(SaveDataSpaceId.User, saveDataInfo[i].SaveDataId).ThrowIfFailure();
+ if (readCount == 0)
+ {
+ break;
+ }
+
+ for (int i = 0; i < readCount; i++)
+ {
+ // TODO: We use Directory.Delete workaround because DeleteSaveData softlock without, due to a bug in LibHac 0.12.0.
+ string savePath = Path.Combine(_virtualFileSystem.GetNandPath(), $"user/save/{saveDataInfo[i].SaveDataId:x16}");
+ string saveMetaPath = Path.Combine(_virtualFileSystem.GetNandPath(), $"user/saveMeta/{saveDataInfo[i].SaveDataId:x16}");
+
+ Directory.Delete(savePath, true);
+ Directory.Delete(saveMetaPath, true);
+
+ _virtualFileSystem.FsClient.DeleteSaveData(SaveDataSpaceId.User, saveDataInfo[i].SaveDataId);
+ }
}
}
}