Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #4206: allow root folders named '/' #4207

Open
wants to merge 19 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 11 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion api/python/quilt3/data_transfer.py
Original file line number Diff line number Diff line change
Expand Up @@ -876,7 +876,7 @@ def copy_file(src: PhysicalKey, dest: PhysicalKey, size=None, message=None, call
"""
def sanity_check(rel_path):
for part in rel_path.split('/'):
if part in ('', '.', '..'):
if part in ('.', '..'):
raise ValueError("Invalid relative path: %r" % rel_path)

url_list = []
Expand Down
4 changes: 1 addition & 3 deletions api/python/quilt3/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,6 @@ def __init__(self, bucket, path, version_id):
assert version_id is None, "Local keys cannot have a version ID"
if os.name == 'nt':
assert '\\' not in path, "Paths must use / as a separator"
else:
assert not path.startswith('/'), "S3 paths must not start with '/'"

self.bucket = bucket
self.path = path
Expand Down Expand Up @@ -511,7 +509,7 @@ def validate_key(key):
)

for part in key.split('/'):
if part in ('', '.', '..'):
if part in ('.', '..'):
drernie marked this conversation as resolved.
Show resolved Hide resolved
raise QuiltException(
f"Invalid key {key!r}. "
f"A package entry key cannot contain a file or folder named '.' or '..' in its path."
Expand Down
2 changes: 2 additions & 0 deletions api/python/tests/integration/test_packages.py
Original file line number Diff line number Diff line change
Expand Up @@ -623,6 +623,8 @@ def test_s3_set_dir(self):

list_object_versions_mock.assert_called_with('bucket', 'foo/')

pkg.set_dir('bar', 's3://bucket//foo') # top-level '/' folder
drernie marked this conversation as resolved.
Show resolved Hide resolved

def test_set_dir_wrong_update_policy(self):
"""Verify non existing update policy raises value error."""
pkg = Package()
Expand Down
6 changes: 6 additions & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ Entries inside each section should be ordered by type:
## CLI
!-->

# unreleased - YYYY-MM-DD

## Python API

* [Fixed] Allow S3 paths starting with `/` in `Package().set_dir()` ([#4207](https://github.com/quiltdata/quilt/pull/4207))

# 6.1.0 - 2024-10-14

## Python API
Expand Down