Skip to content

Commit 306aa9a

Browse files
committed
[SharedCache] Fix metadata not being loaded
Apparently the view metadata is not available until after view init
1 parent 86690fa commit 306aa9a

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

view/sharedcache/core/SharedCacheController.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,9 @@ DSCRef<SharedCacheController> SharedCacheController::Initialize(BinaryView& view
8585

8686
// Check the view auto metadata for shared cache information.
8787
// This effectively restores the state of the opened database to when it was last saved.
88-
auto metadata = view.GetAutoMetadata()->GetKeyValueStore();
89-
if (metadata.find(METADATA_KEY) != metadata.end())
90-
dscView->LoadMetadata(*metadata[METADATA_KEY]);
88+
// NOTE: We store on the parent view because hilariously, the metadata is not present until after view init.
89+
if (const auto metadata = view.GetParentView()->QueryMetadata(METADATA_KEY))
90+
dscView->LoadMetadata(*metadata);
9191

9292
GlobalControllers().insert({id, dscView});
9393
return dscView;
@@ -219,7 +219,8 @@ bool SharedCacheController::ApplyImage(BinaryView& view, const CacheImage& image
219219
m_logger->LogInfoF("Loaded image: '{}'", image.path);
220220

221221
// TODO: This needs to be done in a "database save" callback.
222-
view.StoreMetadata(METADATA_KEY, GetMetadata());
222+
// NOTE: We store on the parent view because hilariously, the view metadata is not available in view init.
223+
view.GetParentView()->StoreMetadata(METADATA_KEY, GetMetadata());
223224

224225
// TODO: Partial failure state (i.e. 2 regions loaded, one failed)
225226
return true;

0 commit comments

Comments
 (0)