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

Rework move_copy/intra_move_copy #354

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Changes from all 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
32 changes: 21 additions & 11 deletions waterbutler/server/api/v1/provider/movecopy.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,17 +134,12 @@ async def move_or_copy(self):
)
self.dest_path = await self.dest_provider.validate_path(**self.json)

if not getattr(self.provider, 'can_intra_' + provider_action)(self.dest_provider, self.path):
# this weird signature syntax courtesy of py3.4 not liking trailing commas on kwargs
conflict = self.json.get('conflict', DEFAULT_CONFLICT)
result = await getattr(tasks, provider_action).adelay(
rename=self.json.get('rename'),
conflict=conflict,
request=remote_logging._serialize_request(self.request),
*self.build_args()
)
metadata, created = await tasks.wait_on_celery(result)
else:
if getattr(self.provider, 'can_intra_' + provider_action)(self.dest_provider, self.path):
# The operation can be done internally to the provider. This would
# be preferred for most operations because it reduces WaterButler's
# bandwith utilization and keeps resources free. Not all providers
# support this, hence the check (Implemented on a provider to
# provider basis).
metadata, created = (
await tasks.backgrounded(
getattr(self.provider, provider_action),
Expand All @@ -155,6 +150,21 @@ async def move_or_copy(self):
conflict=self.json.get('conflict', DEFAULT_CONFLICT),
)
)
else:
# This operation cannot be done inside of the service, using an
# `intra_move` or `intra_copy`. The operation should do the default
# routine of a download and an upload, potentially followed by a
# delete.
conflict = self.json.get('conflict', DEFAULT_CONFLICT)
src_arg, dest_arg = self.build_args()
result = await getattr(tasks, provider_action).adelay(
src_arg,
dest_arg,
rename=self.json.get('rename'),
conflict=conflict,
request=remote_logging._serialize_request(self.request)
)
metadata, created = await tasks.wait_on_celery(result)

self.dest_meta = metadata

Expand Down