Re-organize edge case upload options for my own clarity.

I think setting each of these variables once and simplifing the context they are used in (in the case of purge_upload) makes it more clear what each variable is and how it is set. I also think one, more detailed comment for each variable helps.

Note: This will break run-as-user uploads started prior to the upgrade to 18.XX and executed after the upgrade. It is a small switch to restore the old behavior but I'm not sure it is worth the complexity it adds to the file.

```
run_as_real_user = dataset.get('run_as_real_user', False) or dataset_get.('in_place', True)
```
This commit is contained in:
John Chilton
2017-12-13 12:54:03 -05:00
parent 82f9f8eb98
commit 099c1562fe
2 changed files with 24 additions and 11 deletions
+1 -1
View File
@@ -448,7 +448,7 @@ def create_paramfile(trans, uploaded_datasets):
auto_decompress=getattr(uploaded_dataset, "auto_decompress", True),
purge_source=purge_source,
space_to_tab=uploaded_dataset.space_to_tab,
in_place=trans.app.config.external_chown_script is None,
run_as_real_user=trans.app.config.external_chown_script is None,
check_content=trans.app.config.check_upload_content,
path=uploaded_dataset.path)
# TODO: This will have to change when we start bundling inputs.
+23 -10
View File
@@ -77,14 +77,29 @@ def add_file(dataset, registry, json_file, output_path):
converted_path = None
stdout = None
link_data_only = dataset.get('link_data_only', 'copy_files')
run_as_real_user = in_place = dataset.get('in_place', True)
purge_source = dataset.get('purge_source', True)
# in_place is True if there is no external chmod in place,
# however there are other instances where modifications should not occur in_place:
# when a file is added from a directory on the local file system (ftp import folder or any other path).
if dataset.type in ('server_dir', 'path_paste', 'ftp_import'):
in_place = False
# run_as_real_user is estimated from galaxy config (external chmod indicated of inputs executed)
# If this is True we always purge supplied upload inputs so they are cleaned up and we reuse their
# paths during data conversions since this user already owns that path.
# Older in_place check for upload jobs created before 18.01, TODO remove in 19.XX. xref #5206
run_as_real_user = dataset.get('run_as_real_user', False) or dataset.get("in_place", False)
# purge_source is False if this is an FTP import and ftp_upload_purge has been overridden to False in Galaxy's config.
# This prevents us from deleting the user supplied paths in this case. We disable this behavior
# if running as the real user so the file can be cleaned up by Galaxy.
purge_source = dataset.get('purge_source', True) and not run_as_real_user
# in_place is True only if we are running as a real user and not importing external paths (i.e.
# this is a real upload and not a path paste or ftp import).
# In this case we try to reuse the uploaded file that has been chowned to this user already.
in_place = run_as_real_user and dataset.type not in ('server_dir', 'path_paste', 'ftp_import')
# Base on the check_upload_content Galaxy config option and on by default, this enables some
# security related checks on the uploaded content, but can prevent uploads from working in some cases.
check_content = dataset.get('check_content' , True)
# auto_decompress is a request flag that can be swapped off to prevent Galaxy from automatically
# decompressing archive files before sniffing.
auto_decompress = dataset.get('auto_decompress', True)
try:
ext = dataset.file_type
@@ -303,9 +318,7 @@ def add_file(dataset, registry, json_file, output_path):
if e.errno != errno.EACCES:
raise
elif link_data_only == 'copy_files':
if purge_source and not run_as_real_user:
# if the upload tool runs as a real user the real user
# can't move dataset.path as this path is owned by galaxy.
if purge_source:
shutil.move(dataset.path, output_path)
else:
shutil.copy(dataset.path, output_path)