From fb21610cde255647b934d59107e8c31547c6eb1b Mon Sep 17 00:00:00 2001 From: John Chilton Date: Thu, 9 May 2024 12:49:11 -0400 Subject: [PATCH] Prevent incomplete files from sticking around in the object store cache. Maybe fixes https://github.com/galaxyproject/galaxy/pull/18117. --- lib/galaxy/objectstore/_caching_base.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/galaxy/objectstore/_caching_base.py b/lib/galaxy/objectstore/_caching_base.py index 43c889c98ba7..fd20b015ff28 100644 --- a/lib/galaxy/objectstore/_caching_base.py +++ b/lib/galaxy/objectstore/_caching_base.py @@ -104,7 +104,10 @@ def _pull_into_cache(self, rel_path) -> bool: os.makedirs(self._get_cache_path(rel_path_dir), exist_ok=True) # Now pull in the file file_ok = self._download(rel_path) - fix_permissions(self.config, self._get_cache_path(rel_path_dir)) + if file_ok: + fix_permissions(self.config, self._get_cache_path(rel_path_dir)) + else: + unlink(self._get_cache_path(rel_path), ignore_errors=True) return file_ok def _get_data(self, obj, start=0, count=-1, **kwargs):