From fc189a7c1322229f56e7cf0d859cbc3ab0d0e9d1 Mon Sep 17 00:00:00 2001 From: Liam Fitzgerald Date: Thu, 10 Dec 2020 12:36:59 +1000 Subject: [PATCH] graph-store: on overwrite, archive existing graph --- pkg/arvo/app/graph-store.hoon | 8 +++++++- pkg/arvo/ted/graph/create.hoon | 4 +++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/pkg/arvo/app/graph-store.hoon b/pkg/arvo/app/graph-store.hoon index 5245da238..b90cef665 100644 --- a/pkg/arvo/app/graph-store.hoon +++ b/pkg/arvo/app/graph-store.hoon @@ -257,11 +257,17 @@ ?& !(~(has by archive) resource) !(~(has by graphs) resource) == == + =/ old-graph=(unit marked-graph:store) + (~(get by graphs) resource) ?> (validate-graph graph mark) :_ %_ state graphs (~(put by graphs) resource [graph mark]) update-logs (~(put by update-logs) resource (gas:orm-log ~ ~)) - archive (~(del by archive) resource) + archive + ?~ old-graph + (~(del by archive) resource) + (~(put by archive) resource u.old-graph) + :: validators ?~ mark validators (~(put in validators) u.mark) diff --git a/pkg/arvo/ted/graph/create.hoon b/pkg/arvo/ted/graph/create.hoon index 6e81e6636..315527d0e 100644 --- a/pkg/arvo/ted/graph/create.hoon +++ b/pkg/arvo/ted/graph/create.hoon @@ -37,8 +37,10 @@ :: ?. =(our.bowl entity.rid.action) (strand-fail:strandio %bad-request ~) +=/ overwrite=? + ?=(%policy -.associated.action) =/ =update:graph - [%0 now.bowl %add-graph rid.action *graph:graph mark.action %.n] + [%0 now.bowl %add-graph rid.action *graph:graph mark.action overwrite] ;< ~ bind:m (poke-our %graph-store graph-update+!>(update)) ;< ~ bind:m