Revert LibHac update
Users are facing save destruction on failing extra data update apparently
This commit is contained in:
parent
997380d48c
commit
208ba1dde2
32 changed files with 575 additions and 1805 deletions
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue