Branch: Tag:

2018-03-20

2018-03-20 11:13:09 by Henrik Grubbström (Grubba) <grubba@grubba.org>

RoxenModule: Support inhibition of recursion in recurse_copy_files().

This is needed to support the Depth: 0 header for COPY in WebDAV.

Fixes some of [WS-224].

1709:   //! Specifies how to handle the situation if the destination already   //! exists. See the @[Overwrite] type for details.   //! + //! @param one_level + //! Indicates whether recursion is to be inhibited. + //!   //! @returns   //! Returns a 2xx series status mapping on success (typically 201   //! Created if the destination didn't exist before, or 204 No
1719:   //! response using the info in @[id->get_multi_status()].   mapping(string:mixed) recurse_copy_files(string source, string destination,    PropertyBehavior behavior, -  Overwrite overwrite, RequestID id) +  Overwrite overwrite, RequestID id, +  int|void one_level)   {    SIMPLE_TRACE_ENTER(this, "Recursive copy from %O to %O (%s)",    source, destination,
1739:    MultiStatus.Prefixed result =    id->get_multi_status()->prefix (id->url_base() + prefix);    -  mapping(string:mixed) recurse(string source, string destination) { +  mapping(string:mixed) recurse(string source, string destination, +  int|void one_level) {    // Note: Already got an extra TRACE_ENTER level on entry here.       Stat st = stat_file(source, id);
1747:    TRACE_LEAVE("Source not found.");    return 0;    } -  // FIXME: Check destination? +  // NB: No need to check the destination here, as it is done by +  // copy_collection() and copy_file().    if (st->isdir) {    mapping(string:mixed) res =    copy_collection(source, destination, behavior, overwrite, result, id);
1756:    TRACE_LEAVE("Copy of collection failed.");    return res;    } +  if (!one_level) {    foreach(find_dir(source, id), string filename) {    string subsrc = combine_path_unix(source, filename);    string subdst = combine_path_unix(destination, filename);
1765:    result->add_status(subdst, sub_res->error, sub_res->rettext);    }    } +  }    TRACE_LEAVE("");    return res;    } else {
1774:    };       int start_ms_size = id->multi_status_size(); -  mapping(string:mixed) res = recurse (source, destination); +  mapping(string:mixed) res = recurse (source, destination, one_level);    if (res && res->error != 204 && res->error != 201)    return res;    else if (id->multi_status_size() != start_ms_size)