@@ -1365,26 +1365,24 @@ def __init__(self, s3, path, mode='rb', block_size=5 * 2 ** 20, acl="",
13651365 self .fill_cache = fill_cache
13661366 self .s3_additional_kwargs = s3_additional_kwargs or {}
13671367 self .req_kw = {'RequestPayer' : 'requester' } if requester_pays else {}
1368- super ().__init__ (s3 , path , mode , block_size , autocommit = autocommit ,
1369- cache_type = cache_type )
1370- self .s3 = self .fs # compatibility
1371- if self .writable ():
1368+ if 'r' not in mode :
13721369 if block_size < 5 * 2 ** 20 :
13731370 raise ValueError ('Block size must be >=5MB' )
13741371 else :
1375- if version_id and self . fs .version_aware :
1372+ if version_id and s3 .version_aware :
13761373 self .version_id = version_id
1377- self .details = self . fs . info (self . path , version_id = version_id )
1374+ self .details = s3 . info (path , version_id = version_id )
13781375 self .size = self .details ['size' ]
1379- elif self .fs .version_aware :
1380- self .version_id = self .details .get ('VersionId' )
1376+ elif s3 .version_aware :
13811377 # In this case we have not managed to get the VersionId out of details and
13821378 # we should invalidate the cache and perform a full head_object since it
13831379 # has likely been partially populated by ls.
1384- if self .version_id is None :
1385- self .fs .invalidate_cache (self .path )
1386- self .details = self .fs .info (self .path )
1387- self .version_id = self .details .get ('VersionId' )
1380+ s3 .invalidate_cache (path )
1381+ self .details = s3 .info (path )
1382+ self .version_id = self .details .get ('VersionId' )
1383+ super ().__init__ (s3 , path , mode , block_size , autocommit = autocommit ,
1384+ cache_type = cache_type )
1385+ self .s3 = self .fs # compatibility
13881386
13891387 # when not using autocommit we want to have transactional state to manage
13901388 self .append_block = False
0 commit comments