Skip to content

Commit bc9bf3b

Browse files
committed
Revert "Upgrade to the latest mnemonicdb and fix associated bugs (#2836)"
This reverts commit 61e2ade.
1 parent e384591 commit bc9bf3b

File tree

5 files changed

+25
-19
lines changed

5 files changed

+25
-19
lines changed

Directory.Packages.props

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
<PackageVersion Include="Microsoft.Extensions.TimeProvider.Testing" Version="9.0.0" />
1717
<PackageVersion Include="Nerdbank.FullDuplexStream" Version="1.1.12" />
1818
<PackageVersion Include="Nerdbank.Streams" Version="2.11.79" />
19-
<PackageVersion Include="NexusMods.MnemonicDB" Version="0.9.121" />
20-
<PackageVersion Include="NexusMods.MnemonicDB.Abstractions" Version="0.9.121" />
19+
<PackageVersion Include="NexusMods.MnemonicDB" Version="0.9.114" />
20+
<PackageVersion Include="NexusMods.MnemonicDB.Abstractions" Version="0.9.114" />
2121
<PackageVersion Include="NexusMods.Hashing.xxHash3.Paths" Version="3.0.3" />
2222
<PackageVersion Include="NexusMods.Hashing.xxHash3" Version="3.0.3" />
2323
<PackageVersion Include="NexusMods.Paths" Version="0.15.0" />
@@ -140,7 +140,7 @@
140140
<PackageVersion Include="Humanizer" Version="2.14.1" />
141141
<PackageVersion Include="ini-parser-netstandard" Version="2.5.2" />
142142
<PackageVersion Include="Mutagen.Bethesda.Skyrim" Version="0.44.0" />
143-
<PackageVersion Include="NexusMods.MnemonicDB.SourceGenerator" Version="0.9.121" />
143+
<PackageVersion Include="NexusMods.MnemonicDB.SourceGenerator" Version="0.9.114" />
144144
<PackageVersion Include="NLog.Extensions.Logging" Version="5.3.14" />
145145
<PackageVersion Include="OneOf" Version="3.0.271" />
146146
<PackageVersion Include="ReactiveUI.Fody" Version="19.5.41" />

src/Abstractions/NexusMods.Abstractions.Library.Models/LibraryItem.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public partial struct ReadOnly
3838
public bool TryGetAsDownloadedFile(out DownloadedFile.ReadOnly result) {
3939
// This is same as source generator would make, just that we don't
4040
// currently don't autogenerate conversions for multiple levels of include.
41-
var casted = new DownloadedFile.ReadOnly(Db, EntitySegment, Id);
41+
var casted = new DownloadedFile.ReadOnly(Db, IndexSegment, Id);
4242
if (casted.IsValid()) {
4343
result = casted;
4444
return true;
@@ -54,7 +54,7 @@ public bool TryGetAsDownloadedFile(out DownloadedFile.ReadOnly result) {
5454
public bool TryGetAsLocalFile(out LocalFile.ReadOnly result) {
5555
// This is same as source generator would make, just that we don't
5656
// currently don't autogenerate conversions for multiple levels of include.
57-
var casted = new LocalFile.ReadOnly(Db, EntitySegment, Id);
57+
var casted = new LocalFile.ReadOnly(Db, IndexSegment, Id);
5858
if (casted.IsValid()) {
5959
result = casted;
6060
return true;

src/Abstractions/NexusMods.Abstractions.Loadouts/Models/DiskStateExtensions.cs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
using System.Diagnostics;
21
using DynamicData.Kernel;
32
using NexusMods.Abstractions.GameLocators;
43
using NexusMods.MnemonicDB.Abstractions;
@@ -43,11 +42,8 @@ public static GameInstallMetadata.ReadOnly GetMetadata(this GameInstallation ins
4342
// Get an as-of db for the last applied loadout
4443
var asOfDb = metadata.Db.Connection.AsOf(txId);
4544
// Get the attributes for the entries in the disk state
46-
47-
var ret = DiskStateEntry.FindByGame(asOfDb, metadata.Id);
48-
asOfDb.BulkCache(ret.EntityIds);
49-
50-
return ret;
45+
var segment = asOfDb.Datoms(DiskStateEntry.Game, metadata.Id);
46+
return new Entities<DiskStateEntry.ReadOnly>(new EntityIds(segment, 0, segment.Count), asOfDb);
5147
}
5248

5349
/// <summary>
@@ -57,7 +53,7 @@ public static GameInstallMetadata.ReadOnly GetMetadata(this GameInstallation ins
5753
{
5854
return DiskStateAsOf(metadata, TxId.From(tx.Id.Value));
5955
}
60-
56+
6157
/// <summary>
6258
/// Load the disk state of the game as of the last applied loadout
6359
/// </summary>
@@ -66,9 +62,14 @@ public static GameInstallMetadata.ReadOnly GetMetadata(this GameInstallation ins
6662
// No previously applied loadout, return an empty state
6763
if (!metadata.Contains(GameInstallMetadata.LastSyncedLoadout))
6864
{
69-
return new(new EntityIds { Data = new byte[sizeof(uint)] }, metadata.Db);
65+
return EmptyState;
7066
}
71-
7267
return metadata.DiskStateAsOf(metadata.LastSyncedLoadoutTransaction);
7368
}
69+
70+
private static readonly Entities<DiskStateEntry.ReadOnly> EmptyState = new();
71+
72+
73+
74+
7475
}

src/Abstractions/NexusMods.Abstractions.Resources.DB/PersistedDbResourceLoader.cs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,16 @@ public ValueTask<Resource<byte[]>> LoadResourceAsync(TResourceIdentifier resourc
6969
var db = _connection.Db;
7070
var (entityId, innerResourceIdentifier) = resourceIdentifier;
7171

72+
var persistedResourceId = Optional<EntityId>.None;
7273
var indexSegment = db.Datoms(entityId);
73-
if (!_referenceAttribute.TryGetValue(indexSegment, out var persistedResourceId))
74-
return null;
75-
76-
var persistedResource = PersistedDbResource.Load(db, persistedResourceId);
74+
foreach (var datom in indexSegment)
75+
{
76+
if (!datom.A.Equals(_referenceAttributeId)) continue;
77+
persistedResourceId = _referenceAttribute.ReadValue(datom.ValueSpan, datom.Prefix.ValueTag, _connection.AttributeResolver);
78+
}
79+
80+
if (!persistedResourceId.HasValue) return null;
81+
var persistedResource = PersistedDbResource.Load(db, persistedResourceId.Value);
7782

7883
if (!persistedResource.IsValid()) return null;
7984
if (persistedResource.IsExpired) return null;

src/NexusMods.DataModel.SchemaVersions/Migrations/_0005_MD5Hashes.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public Task Prepare(IDb db)
4040
.Select(entity =>
4141
{
4242
// NOTE(erri120): need to use the IndexSegment because we don't want resolved datoms for removed attributes
43-
foreach (var datom in entity.EntitySegment)
43+
foreach (var datom in entity.IndexSegment)
4444
{
4545
if (attributesToRemove.Contains(datom.A)) return datom;
4646
}

0 commit comments

Comments
 (0)