Skip to content
Permalink
Browse files
fix: XRootDHelper.exists supports non posix filesystem (object store) (
  • Loading branch information
chaen committed Feb 5, 2022
1 parent 5fabffb commit 7a3ad2f438586690dd40e4c8ec591d8c10b22b00
Showing 1 changed file with 21 additions and 13 deletions.
@@ -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

@@ -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)

0 comments on commit 7a3ad2f

Please sign in to comment.