Roxen.git
/
server
/
base_server
/
module.pike
version
»
Context lines:
10
20
40
80
file
none
3
Roxen.git/server/base_server/module.pike:878:
foreach (prefix_locks; PATH; LOCKS) {CODE;} \ } while (0) //! Find some or all locks that apply to @[path]. //! //! @param path //! Normalized path below the filesystem location. //! //! @param recursive //! If @expr{1@} also return locks anywhere below @[path].
+
//! If @expr{-1} return locks anywhere below @[path], but not
+
//! any above @[path]. (This is appropriate to use to get the
+
//! list of locks that need to be unlocked on DELETE.)
//! //! @param exclude_shared //! If @expr{1@} do not return shared locks that are held by users //! other than the one the request is authenticated as. (This is //! appropriate to get the list of locks that would conflict if the //! current user were to make a shared lock.) //! //! @returns //! Returns a multiset containing all applicable locks in //! this location module, or @expr{0@} (zero) if there are none. //! //! @note //! @[DAVLock] objects may be created if the filesystem has some //! persistent storage of them. The default implementation does not //! store locks persistently. //! //! @note //! The default implementation only handles the @expr{"DAV:write"@} //! lock type. multiset(DAVLock) find_locks(string path,
-
int(
0
..1) recursive,
+
int(
-1
..1) recursive,
int(0..1) exclude_shared, RequestID id) { // Common case. if (!sizeof(file_locks) && !sizeof(prefix_locks)) return 0; TRACE_ENTER(sprintf("find_locks(%O, %O, %O, X)", path, recursive, exclude_shared), this); string rsc = resource_id (path, id);
Roxen.git/server/base_server/module.pike:931:
} else add_locks = lambda (mapping(mixed:DAVLock) sub_locks) { locks |= mkmultiset (values (sub_locks)); }; if (file_locks[rsc]) { add_locks (file_locks[rsc]); }
+
if (recursive >= 0) {
foreach(prefix_locks; string prefix; mapping(mixed:DAVLock) sub_locks) { if (has_prefix(rsc, prefix)) { add_locks (sub_locks); break; } }
-
+
}
if (recursive) { LOOP_OVER_BOTH (string prefix, mapping(mixed:DAVLock) sub_locks, { if (has_prefix(prefix, rsc)) { add_locks (sub_locks); } }); } add_locks = 0;
Roxen.git/server/base_server/module.pike:1169:
{ TRACE_ENTER(sprintf("unregister_lock(%O, lock(%O), X).", path, lock->locktoken), this); mixed auth_user = id && authenticated_user_id (path, id); path = resource_id (path, id); DAVLock removed_lock; if (lock->recursive) { if (id) { removed_lock = m_delete(prefix_locks[path], auth_user); } else {
-
foreach(prefix_locks[path]; mixed user; DAVLock l) {
+
foreach(prefix_locks[path]
||([])
; mixed user; DAVLock l) {
if (l == lock) { removed_lock = m_delete(prefix_locks[path], user); } } } if (!sizeof (prefix_locks[path])) m_delete (prefix_locks, path); } else if (file_locks[path]) { if (id) { removed_lock = m_delete (file_locks[path], auth_user); } else {
-
foreach(file_locks[path]; mixed user; DAVLock l) {
+
foreach(file_locks[path]
||([])
; mixed user; DAVLock l) {
if (l == lock) { removed_lock = m_delete(file_locks[path], user); } } } if (!sizeof (file_locks[path])) m_delete (file_locks, path); }
-
ASSERT_IF_DEBUG (lock /*%O*/ == removed_lock /*%O*/, lock, removed_lock);
+
// NB: The lock may have already been removed in the !id case.
+
ASSERT_IF_DEBUG (
!(id || removed_
lock
)
||
+
(lock
/*%O*/ == removed_lock /*%O*/
)
,
+
lock, removed_lock);
TRACE_LEAVE("Ok."); return 0; } //! Register @[lock] on the path @[path] under the assumption that //! there is no other lock already that conflicts with this one, i.e. //! that @expr{check_locks(path,lock->recursive,id)@} would return //! @expr{LOCK_NONE@} if @expr{lock->lockscope@} is //! @expr{"DAV:exclusive"@}, or @expr{<= LOCK_SHARED_AT@} if //! @expr{lock->lockscope@} is @expr{"DAV:shared"@}.
Roxen.git/server/base_server/module.pike:1399:
TRACE_LEAVE("Found match."); SIMPLE_TRACE_LEAVE("Ok%s.", got_sublocks ? " (this level only)" : ""); return got_sublocks; // Found matching sub-condition. } SIMPLE_TRACE_LEAVE("Conditional ok, but still locked (locktoken: %O).", lock->locktoken); locked_fail = 1; }
-
TRACE_LEAVE("Failed.");
+
if (locked_fail) {
+
TRACE_LEAVE("Failed
(locked)
.");
+
} else {
+
TRACE_LEAVE("Precondition failed.");
+
}
return Roxen.http_status(locked_fail ? Protocols.HTTP.DAV_LOCKED : Protocols.HTTP.HTTP_PRECOND_FAILED); } //! Used by some default implementations to check if we may perform a //! write access to @[path]. It should at least call //! @[check_if_header] to check DAV locks. It takes the same arguments //! and has the same return value as that function. //!