Skip to content

Instantly share code, notes, and snippets.

@clayg
Created December 8, 2017 00:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save clayg/6969949a611add5c004a6d4efe3c6f1f to your computer and use it in GitHub Desktop.
Save clayg/6969949a611add5c004a6d4efe3c6f1f to your computer and use it in GitHub Desktop.
maybe anytime we see the symlink header we can follow it regardless of status code?
diff --git a/swift/common/middleware/symlink.py b/swift/common/middleware/symlink.py
index ddcc274..65fe22d 100644
--- a/swift/common/middleware/symlink.py
+++ b/swift/common/middleware/symlink.py
@@ -125,7 +125,7 @@ from swift.common.request_helpers import get_sys_meta_prefix, \
check_path_header
from swift.common.swob import Request, HTTPBadRequest, HTTPTemporaryRedirect, \
HTTPException, HTTPConflict, HTTPPreconditionFailed
-from swift.common.http import is_success, HTTP_REQUESTED_RANGE_NOT_SATISFIABLE
+from swift.common.http import is_success
from swift.common.exceptions import LinkIterError
DEFAULT_SYMLOOP_MAX = 2
@@ -295,16 +295,11 @@ class SymlinkObjectContext(WSGIContext):
def _recursive_get_head(self, req):
resp = self._app_call(req.environ)
- def build_traversal_req():
+ def build_traversal_req(symlink_target):
"""
:returns: new request for target path if it's symlink otherwise
None
"""
- symlink_target = self._response_header_value(
- TGT_OBJ_SYSMETA_SYMLINK_HDR)
- if not symlink_target:
- return None
-
version, _junk = split_path(req.path, 1, 2, True)
target_path = os.path.join(
'/', version, symlink_target.lstrip('/'))
@@ -315,10 +310,12 @@ class SymlinkObjectContext(WSGIContext):
new_req.headers.pop('X-Backend-Storage-Policy-Index', None)
return new_req
- if is_success(self._get_status_int()):
+ symlink_target = self._response_header_value(
+ TGT_OBJ_SYSMETA_SYMLINK_HDR)
+ if symlink_target:
# success case
# format: /<account name>/<container name>/<object name>
- new_req = build_traversal_req()
+ new_req = build_traversal_req(symlink_target)
if not new_req:
# This is the target object which has content.
if self._last_target_path:
@@ -339,15 +336,6 @@ class SymlinkObjectContext(WSGIContext):
return self._recursive_get_head(new_req)
else:
# error case
- # The only case HTTP_REQUEST_NOT_SATISFIABLE from EC policy
- # symlink can continue to traverse to the next target_path
- if self._get_status_int() == \
- HTTP_REQUESTED_RANGE_NOT_SATISFIABLE:
- new_req = build_traversal_req()
- if new_req:
- self._loop_count += 1
- return self._recursive_get_head(new_req)
-
if self._last_target_path:
# Content-Location will be applied only when one or more
# symlink recursion occurred.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment