From e82cca60760d2b7ef021cbfa04ed793cc9516396 Mon Sep 17 00:00:00 2001 From: wbaumann Date: Sun, 7 Jun 2009 18:26:53 +0000 Subject: [PATCH] If file is not found, try to unlock --- ChangeLog | 2 ++ src/webdav.c | 18 +++++++++++++----- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index dee6e7a..d903958 100644 --- a/ChangeLog +++ b/ChangeLog @@ -10,6 +10,8 @@ ChangeLog for davfs2 * cache.c: When upload fails temporarily: retry with increasing delays. + * webdav.c, dav_delete: + If file is not found, try to unlock. 2009-06-06 Werner Baumann (werner.baumann@onlinehome.de) * cache.c, dav_statfs: diff --git a/src/webdav.c b/src/webdav.c index deb6ecd..6b57557 100644 --- a/src/webdav.c +++ b/src/webdav.c @@ -572,17 +572,25 @@ dav_delete(const char *path, time_t *expire) if (ret) return ret; } + struct ne_lock *lock = NULL; char *spath = ne_path_escape(path); ret = ne_delete(session, spath); ret = get_error(ret, "DELETE"); - if (ret == EACCES && lock_discover(spath, expire) == 0) { - ret = ne_delete(session, spath); - ret = get_error(ret, "DELETE"); + if ((ret == EACCES || ret == ENOENT) && locks) { + lock_discover(spath, expire); + lock = lock_by_path(spath); + if (lock && ret == EACCES) { + ret = ne_delete(session, spath); + ret = get_error(ret, "DELETE"); + } else if (lock) { + ne_unlock(session, lock); + ret = 0; + } } - if (!ret && locks && *expire) { - struct ne_lock *lock = lock_by_path(spath); + if (!ret && locks) { + lock = lock_by_path(spath); if (lock) { ne_lockstore_remove(locks, lock); ne_lock_destroy(lock);