diff options
author | David Robillard <d@drobilla.net> | 2018-09-16 11:04:41 +0200 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2018-09-16 11:54:05 +0200 |
commit | 61ff4e6b473453f23b6873d6a5d3e507b8c2a684 (patch) | |
tree | e43101e707096a15ec36f3cadcdffad55da4f12a /src | |
parent | dc81ec3cc0e66af75816d1cb43ab878dd4f2d9b9 (diff) | |
download | lilv-61ff4e6b473453f23b6873d6a5d3e507b8c2a684.tar.gz lilv-61ff4e6b473453f23b6873d6a5d3e507b8c2a684.tar.bz2 lilv-61ff4e6b473453f23b6873d6a5d3e507b8c2a684.zip |
Don't print errors when saving state if correct links already exist
Diffstat (limited to 'src')
-rw-r--r-- | src/state.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/state.c b/src/state.c index 23c1cc4..3c027a7 100644 --- a/src/state.c +++ b/src/state.c @@ -884,6 +884,12 @@ link_exists(const char* path, const void* data) return !matches; } +static int +maybe_symlink(const char* oldpath, const char* newpath) +{ + return link_exists(newpath, oldpath) ? 0 : lilv_symlink(oldpath, newpath); +} + static void write_property_array(const LilvState* state, const PropertyArray* array, @@ -1026,7 +1032,7 @@ lilv_state_make_links(const LilvState* state, const char* dir) && strcmp(state->copy_dir, dir)) { // Link directly to snapshot in the copy directory char* target = lilv_path_relative_to(pm->abs, dir); - lilv_symlink(target, path); + maybe_symlink(target, path); free(target); } else if (!lilv_path_is_child(pm->abs, dir)) { const char* link_dir = state->link_dir ? state->link_dir : dir; @@ -1034,7 +1040,7 @@ lilv_state_make_links(const LilvState* state, const char* dir) if (!strcmp(dir, link_dir)) { // Link directory is save directory, make link at exact path remove(pat); - lilv_symlink(pm->abs, pat); + maybe_symlink(pm->abs, pat); } else { // Make a link in the link directory to external file char* lpath = lilv_find_free_path(pat, link_exists, pm->abs); @@ -1044,7 +1050,7 @@ lilv_state_make_links(const LilvState* state, const char* dir) // Make a link in the save directory to the external link char* target = lilv_path_relative_to(lpath, dir); - lilv_symlink(target, path); + maybe_symlink(target, path); free(target); free(lpath); } |