# Buggy code
def _download(self, rel_path):
    try:
        log.debug(
            "Pulling key '%s' into cache to %s",
            rel_path,
            self._get_cache_path(rel_path),
        )
        key = self._bucket.get_key(rel_path)
        # Test if cache is large enough to hold the new file
        if self.cache_size > 0 and key.size > self.cache_size:
            log.critical(
                "File %s is larger (%s) than the cache size (%s). Cannot download.",
                rel_path,
                key.size,
                self.cache_size,
            )
            return False
        if self.use_axel:
            log.debug(
                "Parallel pulled key '%s' into cache to %s",
                rel_path,
                self._get_cache_path(rel_path),
            )
            ncores = multiprocessing.cpu_count()
            url = key.generate_url(7200)
            ret_code = subprocess.call(["axel", "-a", "-n", ncores, url])
            if ret_code == 0:
                return True
        else:
            log.debug(
                "Pulled key '%s' into cache to %s",
                rel_path,
                self._get_cache_path(rel_path),
            )
            self.transfer_progress = 0  # Reset transfer progress counter
            key.get_contents_to_filename(
                self._get_cache_path(rel_path), cb=self._transfer_cb, num_cb=10
            )
            return True
    except S3ResponseError:
        log.exception(
            "Problem downloading key '%s' from S3 bucket '%s'",
            rel_path,
            self._bucket.name,
        )
    return False


# Traceback (TypeError)
galaxy.objectstore.s3 DEBUG 2020-11-30 12:41:25,364 [p:18802,w:1,m:0] [uWSGIWorker1Core1] Pulling key '000/dataset_74.dat' into cache to /mnt/volume/shared/galaxy/var/database/object_store_cache/000/dataset_74.dat
galaxy.objectstore.s3 DEBUG 2020-11-30 12:41:25,370 [p:18802,w:1,m:0] [uWSGIWorker1Core1] Parallel pulled key '000/dataset_74.dat' into cache to /mnt/volume/shared/galaxy/var/database/object_store_cache/000/dataset_74.dat
galaxy.web.framework.decorators ERROR 2020-11-30 12:41:25,381 [p:18802,w:1,m:0] [uWSGIWorker1Core1] Uncaught exception in exposed API method:
Traceback (most recent call last):
File "/mnt/volume/shared/galaxy/server/lib/galaxy/web/framework/decorators.py", line 282, in decorator
rval = func(self, trans, *args, **kwargs)
File "/mnt/volume/shared/galaxy/server/lib/galaxy/webapps/galaxy/api/folder_contents.py", line 113, in index
library_dataset_dict = content_item.to_dict()
File "/mnt/volume/shared/galaxy/server/lib/galaxy/model/__init__.py", line 3493, in to_dict
file_name=ldda.file_name,
File "/mnt/volume/shared/galaxy/server/lib/galaxy/model/__init__.py", line 2510, in get_file_name
return self.dataset.get_file_name()
File "/mnt/volume/shared/galaxy/server/lib/galaxy/model/__init__.py", line 2221, in get_file_name
return self.object_store.get_filename(self)
File "/mnt/volume/shared/galaxy/server/lib/galaxy/objectstore/__init__.py", line 561, in get_filename
return self._call_method('get_filename', obj, ObjectNotFound, True, **kwargs)
File "/mnt/volume/shared/galaxy/server/lib/galaxy/objectstore/__init__.py", line 587, in _call_method
return store.__getattribute__(method)(obj, **kwargs)
File "/mnt/volume/shared/galaxy/server/lib/galaxy/objectstore/s3.py", line 671, in get_filename
if self._pull_into_cache(rel_path):
File "/mnt/volume/shared/galaxy/server/lib/galaxy/objectstore/s3.py", line 420, in _pull_into_cache
file_ok = self._download(rel_path)
File "/mnt/volume/shared/galaxy/server/lib/galaxy/objectstore/s3.py", line 440, in _download
ret_code = subprocess.call(['axel', '-a', '-n', ncores, url])
File "/usr/lib/python3.6/subprocess.py", line 287, in call
with Popen(*popenargs, **kwargs) as p:
File "/usr/lib/python3.6/subprocess.py", line 729, in __init__
restore_signals, start_new_session)
File "/usr/lib/python3.6/subprocess.py", line 1295, in _execute_child
restore_signals, start_new_session, preexec_fn)
TypeError: expected str, bytes or os.PathLike object, not int

# Fixed code
def _download(self, rel_path):
    try:
        log.debug(
            "Pulling key '%s' into cache to %s",
            rel_path,
            self._get_cache_path(rel_path),
        )
        key = self._bucket.get_key(rel_path)
        # Test if cache is large enough to hold the new file
        if self.cache_size > 0 and key.size > self.cache_size:
            log.critical(
                "File %s is larger (%s) than the cache size (%s). Cannot download.",
                rel_path,
                key.size,
                self.cache_size,
            )
            return False
        if self.use_axel:
            log.debug(
                "Parallel pulled key '%s' into cache to %s",
                rel_path,
                self._get_cache_path(rel_path),
            )
            ncores = multiprocessing.cpu_count()
            url = key.generate_url(7200)
            ret_code = subprocess.call(["axel", "-a", "-n", str(ncores), url])
            if ret_code == 0:
                return True
        else:
            log.debug(
                "Pulled key '%s' into cache to %s",
                rel_path,
                self._get_cache_path(rel_path),
            )
            self.transfer_progress = 0  # Reset transfer progress counter
            key.get_contents_to_filename(
                self._get_cache_path(rel_path), cb=self._transfer_cb, num_cb=10
            )
            return True
    except S3ResponseError:
        log.exception(
            "Problem downloading key '%s' from S3 bucket '%s'",
            rel_path,
            self._bucket.name,
        )
    return False