Skip to content

Commit

Permalink
fix: XRootDHelper.exists supports non posix filesystem (object store) (
Browse files Browse the repository at this point in the history
  • Loading branch information
chaen committed Feb 5, 2022
1 parent 5fabffb commit 7a3ad2f
Showing 1 changed file with 21 additions and 13 deletions.
34 changes: 21 additions & 13 deletions snakemake/remote/XRootD.py
Expand Up @@ -7,6 +7,7 @@
from os.path import abspath, join, normpath
import re

from stat import S_ISREG
from snakemake.remote import AbstractRemoteObject, AbstractRemoteProvider
from snakemake.exceptions import WorkflowError, XRootDFileException

Expand Down Expand Up @@ -142,23 +143,30 @@ def _parse_url(self, url):
return domain, dirname, filename

def exists(self, url):

domain, dirname, filename = self._parse_url(url)
status, dirlist = self.get_client(domain).dirlist(dirname)

status, statInfo = self.get_client(domain).stat(os.path.join(dirname, filename))

if not status.ok:
if status.errno == 3011:
return False
else:
raise XRootDFileException(
"Error listing directory "
+ dirname
+ " on domain "
+ domain
+ "\n"
+ repr(status)
+ "\n"
+ repr(dirlist)
)
return filename in [f.name for f in dirlist.dirlist]
raise XRootDFileException(
"Error stating URL "
+ os.path.join(dirname, filename)
+ " on domain "
+ domain
+ "\n"
+ repr(status)
+ "\n"
+ repr(statInfo)
)

return True
# return not (
# (statInfo.flags & StatInfoFlags.IS_DIR)
# or (statInfo.flags & StatInfoFlags.OTHER)
# )

def _get_statinfo(self, url):
domain, dirname, filename = self._parse_url(url)
Expand Down

0 comments on commit 7a3ad2f

Please sign in to comment.