Skip to content

Commit 26fdedf

Browse files
committed
Fix cloud assets not persisting between sessions
- Force LiteDB checkpoint after installing cloud packages to ensure data is persisted to disk before the editor closes - Clean up stale file entries from old package revisions to prevent validation failures on restart - Fix ValidatePackage to only validate files matching the current package revision
1 parent e0eb3a2 commit 26fdedf

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

engine/Sandbox.Tools/Assets/CloudAssetDirectory.cs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,15 @@ public void Dispose()
9191
public void AddPackage( Package package )
9292
{
9393
packages.DeleteMany( x => x.FullIdent == package.FullIdent );
94+
95+
// Clean up file entries from old revisions to prevent validation failures on restart
96+
files.DeleteMany( x => x.Package == package.FullIdent && x.Revision != package.Revision.VersionId );
97+
9498
packages.Insert( package );
9599

100+
// Force checkpoint to ensure data is persisted to disk
101+
db.Checkpoint();
102+
96103
packageCache[package.FullIdent] = package;
97104
}
98105

@@ -157,12 +164,15 @@ internal Package FindPackage( string ident )
157164
}
158165

159166
/// <summary>
160-
/// Validate that the files in this package are all present and correct. This is
167+
/// Validate that the files in this package are all present and correct. This is
161168
/// done once when retriving the package.
162169
/// </summary>
163170
internal bool ValidatePackage( Package package )
164171
{
165-
return fileCache.Values.Where( x => x.Package == package.FullIdent ).AsParallel().All( x => FileSystem.Cloud.FileExists( x.Path ) );
172+
return fileCache.Values
173+
.Where( x => x.Package == package.FullIdent && x.Revision == package.Revision.VersionId )
174+
.AsParallel()
175+
.All( x => FileSystem.Cloud.FileExists( x.Path ) );
166176
}
167177

168178
/// <summary>

0 commit comments

Comments
 (0)