webapi t=mkdir-with-children and mkdir-immutable: behavior when directory already exists? #903
Labels
No Label
0.2.0
0.3.0
0.4.0
0.5.0
0.5.1
0.6.0
0.6.1
0.7.0
0.8.0
0.9.0
1.0.0
1.1.0
1.10.0
1.10.1
1.10.2
1.10a2
1.11.0
1.12.0
1.12.1
1.13.0
1.14.0
1.15.0
1.15.1
1.2.0
1.3.0
1.4.1
1.5.0
1.6.0
1.6.1
1.7.0
1.7.1
1.7β
1.8.0
1.8.1
1.8.2
1.8.3
1.8β
1.9.0
1.9.0-s3branch
1.9.0a1
1.9.0a2
1.9.0b1
1.9.1
1.9.2
1.9.2a1
LeastAuthority.com automation
blocker
cannot reproduce
cloud-branch
code
code-dirnodes
code-encoding
code-frontend
code-frontend-cli
code-frontend-ftp-sftp
code-frontend-magic-folder
code-frontend-web
code-mutable
code-network
code-nodeadmin
code-peerselection
code-storage
contrib
critical
defect
dev-infrastructure
documentation
duplicate
enhancement
fixed
invalid
major
minor
n/a
normal
operational
packaging
somebody else's problem
supercritical
task
trivial
unknown
was already fixed
website
wontfix
worksforme
No Milestone
No Assignees
3 Participants
Notifications
Due Date
No due date set.
Reference: tahoe-lafs/trac-2024-07-25#903
Loading…
Reference in New Issue
No description provided.
Delete Branch "%!s(<nil>)"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
I'm not entirely clear on what the webapi
POST /uri/$DIRCAP/SUBDIRS../SUBDIR?t=mkdir
calls should do when the given subdirectory already exists. The docs state that for the regular t=mkdir case (i.e. creating an empty mutable directory), "If the named target directory already exists, this will make no changes to it". I believe this is fine.But for the other cases (t=mkdir-with-children, t=mkdir-immutable), the situation gets more interesting. We need to signal whether the new directory was created (and thus has the new contents provided by these calls), or if it already existed (and therefore still has some old contents). There should also be a clear way for the caller to indicate whether they want to get an error when the directory already exists, or if this "return anyways" behavior is ok.
In other calls, we have a "replace=" parameter which is related to this. There was some incomplete code for replace= in mkdir-immutable, and some slightly more complete code in mkdir-with-children, but I don't think the semantics are well defined yet.
t=mkdir-immutable
should clearly fail if the directory doesn't exist (because then it can't be created as immutable without first deleting it, and the operation didn't ask to do that).Also, I don't think that automatically creating the intermediate directories makes a lot of sense for the
mkdir-immutable
-with-path operations:So I think that a
mkdir-immutable
-with-path should fail if the intermediate directories don't already exist (in which case, they must obviously be mutable). Explicit Is Better Than Implicit.Replying to davidsarah:
I meant, if the directory already exists.
So, I would suggest to strip out support for
replace=
inmkdir-immutable
.For
mkdir-with-children
, it makes sense forreplace=true
to imply the same semantics asset_children
. That has anoverwrite
parameter to control whether existing children can be overwritten without error. So there would be three cases when the directory already exists:replace=false
: error (regardless ofoverwrite
setting)replace=true&overwrite=false
: works likeset_children
withoverwrite=false
replace=true&overwrite=true
: works likeset_children
withoverwrite=true
webapi t=mkdir: behavior when directory already exists?to webapi t=mkdir-with-children and mkdir-immutable: behavior when directory already exists?Oh, and blocking files should never be replaced with directories regardless of the settings of
replace
oroverwrite
.sounds good to me
Looking at
create_subdirectory
in dirnode.py, it seems that the current support forreplace=true
inmkdir-with-children
is doing something that is likely to be unexpected: it creates the new subdirectory with its children, and then overwrites the entry with the given name, effectively unlinking it (regardless of its type -- directory, file, or unknown).Leaving this code as it is would create a forward-compatibility problem if we want to change the semantics to something similar to comment:74674, because a webapi client could not safely use
replace=true
and get consistent semantics between v1.6 and v1.7+. It would be better to always passoverwrite=False
tocreate_subdirectory
in this version, so that future clients that depend on the 1.7 semantics forreplace=true
(if we support it at all) will get an error with 1.6. That would be consistent with webapi.txt which doesn't mention anyreplace
parameter.Attachment remove-mkdir-replace-darcspatch.txt (39947 bytes) added
Remove replace= parameter to mkdir-immutable and mkdir-with-children
Review needed for 1.6.
Looks good! Thanks for catching this potential forward-compatibility issue. Applied your patch as changeset:26ab58e0062e6921.
This ticket should stay open until we decide whether or how to define
replace=true
, but the semantics withoutreplace
are now well-defined, so it can be downgraded to minor.webapi.txt is being changed for #833, so I'll include documentation that these commands return an error when the child already exists in that patch.