@@ -492,7 +492,7 @@ def listdir(self, path):
492
492
if name :
493
493
_directory .append (name )
494
494
495
- if not _directory :
495
+ if self . strict and not _directory :
496
496
if not self .getinfo (_path ).is_dir :
497
497
raise errors .DirectoryExpected (path )
498
498
@@ -503,7 +503,7 @@ def makedir(self, path, permissions=None, recreate=False):
503
503
_path = self .validatepath (path )
504
504
_key = self ._path_to_dir_key (_path )
505
505
506
- if not self .isdir (dirname (_path )):
506
+ if self . strict and not self .isdir (dirname (_path )):
507
507
raise errors .ResourceNotFound (path )
508
508
509
509
try :
@@ -543,23 +543,24 @@ def on_close_create(s3file):
543
543
finally :
544
544
s3file .raw .close ()
545
545
546
- try :
547
- dir_path = dirname (_path )
548
- if dir_path != "/" :
549
- _dir_key = self ._path_to_dir_key (dir_path )
550
- self ._get_object (dir_path , _dir_key )
551
- except errors .ResourceNotFound :
552
- raise errors .ResourceNotFound (path )
546
+ if self .strict :
547
+ try :
548
+ dir_path = dirname (_path )
549
+ if dir_path != "/" :
550
+ _dir_key = self ._path_to_dir_key (dir_path )
551
+ self ._get_object (dir_path , _dir_key )
552
+ except errors .ResourceNotFound :
553
+ raise errors .ResourceNotFound (path )
553
554
554
- try :
555
- info = self ._getinfo (path )
556
- except errors .ResourceNotFound :
557
- pass
558
- else :
559
- if _mode .exclusive :
560
- raise errors .FileExists (path )
561
- if info .is_dir :
562
- raise errors .FileExpected (path )
555
+ try :
556
+ info = self ._getinfo (path )
557
+ except errors .ResourceNotFound :
558
+ pass
559
+ else :
560
+ if _mode .exclusive :
561
+ raise errors .FileExists (path )
562
+ if info .is_dir :
563
+ raise errors .FileExpected (path )
563
564
564
565
s3file = S3File .factory (path , _mode , on_close = on_close_create )
565
566
if _mode .appending :
@@ -692,9 +693,10 @@ def scandir(self, path, namespaces=None, page=None):
692
693
_s3_key = self ._path_to_dir_key (_path )
693
694
prefix_len = len (_s3_key )
694
695
695
- info = self .getinfo (path )
696
- if not info .is_dir :
697
- raise errors .DirectoryExpected (path )
696
+ if self .strict :
697
+ info = self .getinfo (path )
698
+ if not info .is_dir :
699
+ raise errors .DirectoryExpected (path )
698
700
699
701
paginator = self .client .get_paginator ("list_objects" )
700
702
_paginate = paginator .paginate (
0 commit comments