Branch: Tag:

2018-03-22

2018-03-22 13:49:05 by Henrik Grubbström (Grubba) <grubba@grubba.org>

RoxenModule [WebDAV]: Added API function unlock_path().

This function is intended to be used after a path has been deleted,
and to unlock any locks under the path.

909:    return sizeof(locks) && locks;   }    + //! Unlock any locks pertaining to @[path] or to anything + //! under @[path]. + //! + //! This function is used to unlock locks after files or + //! directories have been deleted. + //! + //! The default implementation just unregisters the locks. + //! + //! @seealso + //! @[unregister_lock()] + void unlock_path(string path, RequestID id) + { +  // Common case. +  if (!sizeof(file_locks) && !sizeof(prefix_locks)) return 0; +  +  TRACE_ENTER(sprintf("unlock_path(%O, %O)", path, id), this); +  +  string rsc = resource_id(path, id); +  +  foreach(file_locks; string prefix; mapping(mixed:DAVLock) sub_locks) { +  if (has_prefix(prefix, rsc)) { +  TRACE_ENTER(sprintf("Unlocking %d locks for path %O...", +  sizeof(sub_locks), prefix), this); +  m_delete(file_locks, prefix); +  TRACE_LEAVE(""); +  } +  } +  +  foreach(prefix_locks; string prefix; mapping(mixed:DAVLock) sub_locks) { +  if (has_prefix(prefix, rsc)) { +  TRACE_ENTER(sprintf("Unlocking %d locks for path %O...", +  sizeof(sub_locks), prefix), this); +  m_delete(prefix_locks, prefix); +  TRACE_LEAVE(""); +  } +  } +  +  TRACE_LEAVE("Done."); + } +    //! Check if there are one or more locks that apply to @[path] for the   //! user the request is authenticated as.   //!