@@ -220,6 +220,8 @@ def open(
220220 return dvc_fs .open (path , mode = mode , encoding = encoding , ** kwargs )
221221
222222 def exists (self , path ) -> bool :
223+ path = os .path .abspath (path )
224+
223225 fs , dvc_fs = self ._get_fs_pair (path )
224226
225227 if not dvc_fs :
@@ -231,18 +233,21 @@ def exists(self, path) -> bool:
231233 if fs .exists (path ):
232234 return True
233235
234- try :
235- info = dvc_fs .info (path )
236- except FileNotFoundError :
236+ if not dvc_fs .exists (path ):
237237 return False
238238
239- for out in info ["outs" ]:
240- if fs .exists (out .fs_path ):
241- return False
239+ for p in self .path .parents (path ):
240+ try :
241+ if fs .info (p )["type" ] != "directory" :
242+ return False
243+ except FileNotFoundError :
244+ continue
242245
243246 return True
244247
245248 def isdir (self , path ): # pylint: disable=arguments-renamed
249+ path = os .path .abspath (path )
250+
246251 fs , dvc_fs = self ._get_fs_pair (path )
247252
248253 if dvc_fs and dvc_fs .repo .dvcignore .is_ignored_dir (path ):
@@ -263,9 +268,12 @@ def isdir(self, path): # pylint: disable=arguments-renamed
263268 except FileNotFoundError :
264269 return False
265270
266- for out in info ["outs" ]:
267- if fs .exists (out .fs_path ):
268- return False
271+ for p in self .path .parents (path ):
272+ try :
273+ if fs .info (p )["type" ] != "directory" :
274+ return False
275+ except FileNotFoundError :
276+ continue
269277
270278 return info ["type" ] == "directory"
271279
@@ -274,6 +282,8 @@ def isdvc(self, path, **kwargs):
274282 return dvc_fs is not None and dvc_fs .isdvc (path , ** kwargs )
275283
276284 def isfile (self , path ): # pylint: disable=arguments-renamed
285+ path = os .path .abspath (path )
286+
277287 fs , dvc_fs = self ._get_fs_pair (path )
278288
279289 if dvc_fs and dvc_fs .repo .dvcignore .is_ignored_file (path ):
@@ -294,10 +304,12 @@ def isfile(self, path): # pylint: disable=arguments-renamed
294304 except FileNotFoundError :
295305 return False
296306
297- (out ,) = info ["outs" ]
298- assert len (info ["outs" ]) == 1
299- if fs .exists (out .fs_path ):
300- return False
307+ for p in self .path .parents (path ):
308+ try :
309+ if fs .info (p )["type" ] != "directory" :
310+ return False
311+ except FileNotFoundError :
312+ continue
301313
302314 return info ["type" ] == "file"
303315
0 commit comments