Either delimiter option is not properly documented or has a bug
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
OpenStack Object Storage (swift) |
Fix Released
|
Undecided
|
Unassigned |
Bug Description
Setting just the delimiter (without a prefix) results in behavior that is different from setting both parameters.
Example to illustrate the problem:
1. Create the following objects in a container: /dir, /dir/subdir/foo, dir, dir/subdir/foo
2. Issue a query that sets the delimiter to "/" and prefix to "/"
Expected result: subdir: "/dir/", blobs: "/dir"
Actual result: subdir: "/dir/", blobs: "/dir" -- this is correct
3. Issue a query that sets the prefix to "" and delimiter to "/"
Expected result: subdir: ["/", "dir/"]
Actual result: subdir: ["dir/"], blobs: ["/dir", "/dir/subdir/foo", "dir"]
This is really puzzling, as for keys that start with the delimiter, _all_ keys are listed, even if they include multiple occurrences of the delimiter. This behavior seems wrong to me.
This is also interesting given the documentation for the path option: "Equivalent to setting delimiter to / and prefix to the path with a / at the end." However, this is not correct. Setting path to "" should then be the same as setting delimiter to "/" and prefix to "/", however, the actual results from setting path to "" are: "dir".
I am observing this behavior with Swift 2.2.1 (Rackspace), 2.2.2 (docker-swift), and 2.3.0-rc2 (also, as docker-swift). Note: this problem is not specific to using "/" as a delimiter. The same issue appears if "-" is used, for example.
I'm also not clear (from the documentation), what the expected output should be when keys start with the delimiter and there is no prefix.
I submitted a commit for review that adds a unit test for this behavior and changes the delimiter handling when the key begins with the delimiter character.