Skip to content

Commit

Permalink
Merge pull request #17388 from davelopez/update_webdav_conf_sample
Browse files Browse the repository at this point in the history
[23.1] Set webdav file source to use temp files by default
  • Loading branch information
davelopez authored Feb 2, 2024
2 parents 11fdad0 + 7d27634 commit f7e6d16
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/galaxy/config/sample/file_sources_conf.yml.sample
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@
root: ${user.preferences['owncloud|root']}
login: ${user.preferences['owncloud|username']}
password: ${user.preferences['owncloud|password']}
# By default, the plugin will use temp files to avoid loading entire files into memory.
# You can change the directory here or omit to use the default temp directory.
temp_path: /your/temp/path
# Set writable to true if you have write access to this source
# and want to allow exporting files to it, by default is read only.
writable: false

- type: posix
root: '/data/5/galaxy_import/galaxy_user_data/covid-19/data/sequences/'
Expand Down
6 changes: 6 additions & 0 deletions lib/galaxy/files/sources/webdav.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
except ImportError:
WebDAVFS = None

import tempfile
from typing import (
Optional,
Union,
Expand All @@ -22,6 +23,11 @@ class WebDavFilesSource(PyFilesystem2FilesSource):

def _open_fs(self, user_context=None, opts: Optional[FilesSourceOptions] = None):
props = self._serialization_props(user_context)
use_temp_files = props.pop("use_temp_files", None)
if use_temp_files is None:
# Default to True to avoid memory issues with large files.
props["use_temp_files"] = True
props["temp_path"] = props.get("temp_path", tempfile.TemporaryDirectory(prefix="webdav_"))
extra_props: Union[FilesSourceProperties, dict] = opts.extra_props or {} if opts else {}
handle = WebDAVFS(**{**props, **extra_props})
return handle
Expand Down

0 comments on commit f7e6d16

Please sign in to comment.