Fix a bug when ensuring bcat saves exist

This commit is contained in:
Alex Barney 2023-01-25 23:27:40 -07:00
parent fe2549cb2a
commit 903942b2f4
2 changed files with 87 additions and 1 deletions

View file

@ -210,7 +210,7 @@ public static class ApplicationSaveDataManagement
if (bcatDeliveryCacheStorageSize > 0)
{
Result res = SaveDataFilter.Make(out SaveDataFilter filter, programId: default, SaveDataType.Bcat,
Result res = SaveDataFilter.Make(out SaveDataFilter filter, applicationId.Value, SaveDataType.Bcat,
userId: default, saveDataId: default, index: default);
if (res.IsFailure()) return res.Miss();

View file

@ -45,6 +45,35 @@ public class ApplicationSaveDataManagementTests
Assert.Equal(SaveDataType.Account, info[0].Type);
}
}
[Fact]
public static void EnsureApplicationSaveData_CreatesMultipleAccountSaveData_AllSavesExist()
{
FileSystemClient fs = FileSystemServerFactory.CreateClient(true);
var userId = new Uid(2, 3);
var controlProperty = new ApplicationControlProperty
{
UserAccountSaveDataSize = 0x1000,
UserAccountSaveDataJournalSize = 0x1000
};
Assert.Success(fs.EnsureApplicationSaveData(out _, new Ncm.ApplicationId(11), in controlProperty, in userId));
Assert.Success(fs.EnsureApplicationSaveData(out _, new Ncm.ApplicationId(12), in controlProperty, in userId));
AssertSaveExists();
void AssertSaveExists()
{
using var iterator = new UniqueRef<SaveDataIterator>();
fs.OpenSaveDataIterator(ref iterator.Ref, SaveDataSpaceId.User);
var info = new SaveDataInfo[3];
Assert.Success(iterator.Get.ReadSaveDataInfo(out long entriesRead, info));
Assert.Equal(2, entriesRead);
}
}
[Fact]
public static void EnsureApplicationSaveData_CreatesDeviceSaveData()
@ -81,6 +110,35 @@ public class ApplicationSaveDataManagementTests
}
}
[Fact]
public static void EnsureApplicationSaveData_CreatesMultipleDeviceSaveData_AllSavesExist()
{
FileSystemClient fs = FileSystemServerFactory.CreateClient(true);
var userId = new Uid(2, 3);
var controlProperty = new ApplicationControlProperty
{
DeviceSaveDataSize = 0x1000,
DeviceSaveDataJournalSize = 0x1000
};
Assert.Success(fs.EnsureApplicationSaveData(out _, new Ncm.ApplicationId(11), in controlProperty, in userId));
Assert.Success(fs.EnsureApplicationSaveData(out _, new Ncm.ApplicationId(12), in controlProperty, in userId));
AssertSaveExists();
void AssertSaveExists()
{
using var iterator = new UniqueRef<SaveDataIterator>();
fs.OpenSaveDataIterator(ref iterator.Ref, SaveDataSpaceId.User);
var info = new SaveDataInfo[3];
Assert.Success(iterator.Get.ReadSaveDataInfo(out long entriesRead, info));
Assert.Equal(2, entriesRead);
}
}
[Fact]
public static void EnsureApplicationSaveData_CreatesBcatCacheStorage()
{
@ -115,6 +173,34 @@ public class ApplicationSaveDataManagementTests
}
}
[Fact]
public static void EnsureApplicationSaveData_CreatesMultipleBcatCacheStorages_AllSavesExist()
{
FileSystemClient fs = FileSystemServerFactory.CreateClient(true);
var userId = new Uid(2, 3);
var controlProperty = new ApplicationControlProperty
{
BcatDeliveryCacheStorageSize = 0x1000
};
Assert.Success(fs.EnsureApplicationSaveData(out _, new Ncm.ApplicationId(11), in controlProperty, in userId));
Assert.Success(fs.EnsureApplicationSaveData(out _, new Ncm.ApplicationId(12), in controlProperty, in userId));
AssertSaveExists();
void AssertSaveExists()
{
using var iterator = new UniqueRef<SaveDataIterator>();
fs.OpenSaveDataIterator(ref iterator.Ref, SaveDataSpaceId.User);
var info = new SaveDataInfo[3];
Assert.Success(iterator.Get.ReadSaveDataInfo(out long entriesRead, info));
Assert.Equal(2, entriesRead);
}
}
[Fact]
public static void EnsureApplicationSaveData_CreatesTemporaryStorage()
{