return error;
}
+static void
+delete_rpp(struct rpki_uri *notif)
+{
+ char *path = uri_get_rrdp_workspace(notif);
+ pr_val_debug("Snapshot: Deleting cached RPP '%s'.", path);
+ file_rm_rf(path);
+ free(path);
+}
+
static int
xml_read_snapshot(xmlTextReaderPtr reader, void *arg)
{
struct rpki_uri *uri;
int error;
+ delete_rpp(notif->uri);
+
uri = notif->snapshot.uri;
pr_val_debug("Processing snapshot '%s'.", uri_val_get_printable(uri));
{
return parser->len == 2
&& parser->token[0] == '.'
- && parser->token[1] == '.' ;
+ && parser->token[1] == '.';
}
static int
return 0;
}
+static int
+get_rrdp_workspace(struct path_builder *pb, struct rpki_uri *notif)
+{
+ int error;
+
+ error = pb_init_cache(pb, "rrdp");
+ if (error)
+ return error;
+
+ error = append_guri(pb, notif->global, "https://", ENOTHTTPS, true);
+ if (error)
+ pb_cleanup(pb);
+ return error;
+}
+
/*
* Maps "rsync://a.b.c/d/e.cer" into "<local-repository>/rsync/a.b.c/d/e.cer".
*/
struct path_builder pb;
int error;
- error = pb_init_cache(&pb, "rrdp");
- if (error)
- return error;
- error = append_guri(&pb, notif->global, "https://", ENOTHTTPS, true);
+ error = get_rrdp_workspace(&pb, notif);
if (error)
return error;
error = append_guri(&pb, uri->global, "rsync://", ENOTRSYNC, true);
- if (error)
+ if (error) {
+ pb_cleanup(&pb);
return error;
+ }
uri->local = pb.string;
return 0;
return uri_get_printable(uri, format);
}
+char *
+uri_get_rrdp_workspace(struct rpki_uri *notif)
+{
+ struct path_builder pb;
+ return (get_rrdp_workspace(&pb, notif) == 0) ? pb.string : NULL;
+}
+
DEFINE_ARRAY_LIST_FUNCTIONS(uri_list, struct rpki_uri *, static)
void
char const *uri_val_get_printable(struct rpki_uri *);
char const *uri_op_get_printable(struct rpki_uri *);
+char *uri_get_rrdp_workspace(struct rpki_uri *);
+
/* Plural */
DEFINE_ARRAY_LIST_STRUCT(uri_list, struct rpki_uri *);