Skip to content

Commit

Permalink
fix model key generation
Browse files Browse the repository at this point in the history
  • Loading branch information
adamhathcock committed Dec 2, 2024
1 parent 8e5d874 commit 7f34c97
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public class TeklaDocumentModelStore : DocumentModelStore
private readonly ILogger<TeklaDocumentModelStore> _logger;
private readonly ISqLiteJsonCacheManager _jsonCacheManager;
private readonly TSM.Events _events;
private readonly TSM.Model _model;
private string? _modelKey;

public TeklaDocumentModelStore(
Expand All @@ -24,10 +25,11 @@ ISqLiteJsonCacheManagerFactory jsonCacheManagerFactory
_logger = logger;
_jsonCacheManager = jsonCacheManagerFactory.CreateForUser("ConnectorsFileData");
_events = new TSM.Events();
_model = new TSM.Model();
GenerateKey();
_events.ModelLoad += () =>
{
var model = new TSM.Model();
_modelKey = Crypt.Md5(model.GetInfo().ModelPath, length: 32);
GenerateKey();
LoadState();
OnDocumentChanged();
};
Expand All @@ -39,6 +41,8 @@ ISqLiteJsonCacheManagerFactory jsonCacheManagerFactory
}
}

private void GenerateKey() => _modelKey = Crypt.Md5(_model.GetInfo().ModelPath, length: 32);

protected override void HostAppSaveState(string modelCardState)
{
try
Expand Down

0 comments on commit 7f34c97

Please sign in to comment.