Skip to content

Commit 9095891

Browse files
committed
[WARP] Push added functions and types to network containers cache
This makes them immediately available, and works around the issue of invalidating the entire cache to allow for retrieving of locally pushed data
1 parent bf38450 commit 9095891

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

plugins/warp/src/container/network.rs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,16 @@ impl Container for NetworkContainer {
287287
source: &SourceId,
288288
types: &[ComputedType],
289289
) -> ContainerResult<()> {
290-
self.cache.add_computed_types(source, types)
290+
// NOTE: We must `add_computed_types` to the cache before we add the chunk, as `added_chunks` is
291+
// not consulted when retrieving types from the cache, if we fail to add the types to
292+
// the cache, we will not see them show up in the UI or when matching.
293+
self.cache.add_computed_types(source, types)?;
294+
let type_chunk = TypeChunk::new_with_computed(types).ok_or(
295+
ContainerError::CorruptedData("signature chunk failed to validate"),
296+
)?;
297+
let chunk = Chunk::new(ChunkKind::Type(type_chunk), CompressionType::None);
298+
self.added_chunks.entry(*source).or_default().push(chunk);
299+
Ok(())
291300
}
292301

293302
fn remove_types(&mut self, source: &SourceId, guids: &[TypeGUID]) -> ContainerResult<()> {
@@ -300,6 +309,10 @@ impl Container for NetworkContainer {
300309
source: &SourceId,
301310
functions: &[Function],
302311
) -> ContainerResult<()> {
312+
// NOTE: We must `add_functions` to the cache before we add the chunk, as `added_chunks` is
313+
// not consulted when retrieving functions from the cache, if we fail to add the functions to
314+
// the cache, we will not see them show up in the UI or when matching.
315+
self.cache.add_functions(target, source, functions)?;
303316
let signature_chunk = SignatureChunk::new(functions).ok_or(
304317
ContainerError::CorruptedData("signature chunk failed to validate"),
305318
)?;

0 commit comments

Comments
 (0)