Branch: Tag:

2018-02-01

2018-02-01 15:50:12 by Henrik Grubbström (Grubba) <grubba@grubba.org>

WebDAV: Extended API for find_locks().

A recursion value of -1 now causes find_locks() to only list
locks that are rooted at path or below, but not any above.
This can be used to find the locks to be invalidated if the
specified path were to be deleted.

Fixes some of [WS-160].

1:   // This file is part of Roxen WebServer.   // Copyright © 1996 - 2004, Roxen IS. - // $Id: module.pike,v 1.234 2008/12/11 17:17:43 jonasw Exp $ + // $Id$      #include <module_constants.h>   #include <module.h>
799:   //!   //! @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
819:   //! 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)   {
852:    add_locks (file_locks[rsc]);    }    +  if (recursive >= 0) {    foreach(prefix_locks;    string prefix; mapping(mixed:DAVLock) sub_locks) {    if (has_prefix(rsc, prefix)) {
859:    break;    }    } +  }       if (recursive) {    LOOP_OVER_BOTH (string prefix, mapping(mixed:DAVLock) sub_locks, {