Skip to content

Commit 2a359f8

Browse files
committed
Don't insert asset uploader or their stats
1 parent b2f3a9e commit 2a359f8

1 file changed

Lines changed: 9 additions & 5 deletions

File tree

Refresh.Database/GameDatabaseContext.Assets.cs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,15 @@ public IEnumerable<GameAsset> GetAssetsByType(GameAssetType type) =>
7575
this.GameAssetsIncluded
7676
.Where(a => a.AssetType == type);
7777

78-
public void AddAssetToDatabase(GameAsset asset) =>
79-
this.Write(() =>
80-
{
81-
this.GameAssets.Add(asset);
82-
});
78+
public void AddAssetToDatabase(GameAsset asset)
79+
{
80+
// Ensure that we're tracking the user as unchanged so postgres won't try to insert them
81+
if (asset.OriginalUploader != null)
82+
this.GameUsers.Attach(asset.OriginalUploader);
83+
84+
this.GameAssets.Add(asset);
85+
this.SaveChanges();
86+
}
8387

8488
public void AddAssetsToDatabase(IEnumerable<GameAsset> assets)
8589
{

0 commit comments

Comments
 (0)