#357 closed enhancement (fixed)

mkdir -p in the wapi

Reported by: zooko Owned by: warner
Priority: major Milestone: 1.1.0
Component: code-frontend-web Version: 0.9.0
Keywords: Cc:
Launchpad Bug:

Description

Extend the POST /uri?t=mkdir to optionally take a /uri/$CAP[/optionalpath] instead of just uri, and if there is a CAP+optional_path, then it does "mkdir -p" behavior -- creating any needed by not present parent dirs of the new dir.

Change History (3)

comment:1 Changed at 2008-03-19T20:50:29Z by robk

  • Owner changed from zooko to warner

From recent discussion, primarily on IRC, with Brian and Zooko, my understanding of the consensus was thus;

currently a POST with ?t=mkdir is valid in two forms;

  • /uri/SOME_URI?t=mkdir&name=new_dir_name
  • /uri/SOME_URI/some/path/to/an/existing/dir?t=mkdir&name=new_dir_name

by contrast, the PUT requests by which a file (or a uri) can be added can specify a path which may-or-may-not exist, and the PUT logic will retrieve extant, and create new intermediary directories as necessary to ensure the target path exists.

the preferred (ideal) api for 'mkdir -p' functionality would be

  • /uri/SOME_URI/some/path/which/may/or/may/not/exist?t=mkdir&name=new_dir_name

however, the current webish request handling code makes that a challenge.

specifically, the make-directories-as-required code is only present in the PUT handling code. the POST handling code requires that the target of the post be an extant node before a POST request can be dispatched.

pending a refactoring of the webish request handling to make this preferred api simpler to implement, and motivated by the MV->T migration efforts which had need of mkdir-p functionality (and soon), I implemented a less ideal api which fitted better into the current webish request handling.

  • /uri/SOME_URI?t=mkdir-p&path=/path/to/some/directory

this will return the URI for the specified subdirectory of the given uri. naturally if the directory exists, it's existing uri is returned, if not it, and any intermediary directories, are created and the final directory's uri returned.

this is implemented in fa3feda37c58f2eb and 5e7eae02322cfddb

I believe Brian was planning on looking into webish request dispatch refactoring.

comment:2 Changed at 2008-04-14T16:55:01Z by zooko

These patches are now listed as trac changesets a7fe82f6b06eae8f and 5e4a0c72123d017c.

comment:3 Changed at 2008-06-01T20:17:20Z by warner

  • Milestone changed from undecided to 1.1.0
  • Resolution set to fixed
  • Status changed from new to closed

This one is finished: the new preferred API for 'mkdir -p' is:

  • POST /uri/SOME_URI/some/path/which/may/or/may/not/exist?t=mkdir

When this returns, a directory named "exist" will exist.

Note: See TracTickets for help on using tickets.