summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2020-01-18 15:28:45 +0100
committerDavid Robillard <d@drobilla.net>2020-01-18 15:32:59 +0100
commit1bb1de7ecd19a99a1a29a9a4d734fcc38c2ba9cc (patch)
tree3859acfcfb432639fa29faedf3beec609867cbf7 /src
parentc9a54e019d54cbccfff742d5c5662ff021b187a9 (diff)
downloadlilv-1bb1de7ecd19a99a1a29a9a4d734fcc38c2ba9cc.tar.gz
lilv-1bb1de7ecd19a99a1a29a9a4d734fcc38c2ba9cc.tar.bz2
lilv-1bb1de7ecd19a99a1a29a9a4d734fcc38c2ba9cc.zip
Fix deleting state bundles loaded from the model
Diffstat (limited to 'src')
-rw-r--r--src/state.c25
1 files changed, 18 insertions, 7 deletions
diff --git a/src/state.c b/src/state.c
index 5c3b90c..7e0f50d 100644
--- a/src/state.c
+++ b/src/state.c
@@ -1276,13 +1276,24 @@ lilv_state_delete(LilvWorld* world,
try_unlink(state->dir, manifest_path);
// Remove all known files from state bundle
- for (ZixTreeIter* i = zix_tree_begin(state->abs2rel);
- i != zix_tree_end(state->abs2rel);
- i = zix_tree_iter_next(i)) {
- const PathMap* pm = (const PathMap*)zix_tree_get(i);
- char* path = lilv_path_join(state->dir, pm->rel);
- try_unlink(state->dir, path);
- free(path);
+ if (state->abs2rel) {
+ // State created from instance, get paths from map
+ for (ZixTreeIter* i = zix_tree_begin(state->abs2rel);
+ i != zix_tree_end(state->abs2rel);
+ i = zix_tree_iter_next(i)) {
+ const PathMap* pm = (const PathMap*)zix_tree_get(i);
+ char* path = lilv_path_join(state->dir, pm->rel);
+ try_unlink(state->dir, path);
+ free(path);
+ }
+ } else {
+ // State loaded from model, get paths from loaded properties
+ for (uint32_t i = 0; i < state->props.n; ++i) {
+ const Property* const p = &state->props.props[i];
+ if (p->type == state->atom_Path) {
+ try_unlink(state->dir, (const char*)p->value);
+ }
+ }
}
if (rmdir(state->dir)) {