@@ -1117,10 +1117,7 @@ def set_metadata(self, path, metadata_name=None, metadata_values=None, key=None)
1117
1117
logger .debug ("writing metadata '%s' '%s'" % (path , key ))
1118
1118
md = key .metadata
1119
1119
md ['Content-Type' ] = key .content_type # Otherwise we loose the Content-Type with S3 Copy
1120
- if key .size > 0 :
1121
- key .copy (key .bucket .name , key .name , md , preserve_acl = False ) # Do I need to preserve ACL?
1122
- else :
1123
- key .set_contents_from_string ('' ); # Better for empry objects ???
1120
+ key .copy (key .bucket .name , key .name , md , preserve_acl = False ) # Do I need to preserve ACL?
1124
1121
self .publish (['md' , metadata_name , path ])
1125
1122
1126
1123
def getattr (self , path , fh = None ):
@@ -1163,6 +1160,7 @@ def readdir(self, path, fh=None):
1163
1160
dirs = self .cache .get (path , 'readdir' )
1164
1161
1165
1162
if not dirs :
1163
+ logger .debug ("readdir '%s' '%s' no cache" % (path , fh ))
1166
1164
full_path = self .join_prefix (path )
1167
1165
if full_path == '.' :
1168
1166
full_path = ''
@@ -1174,11 +1172,14 @@ def readdir(self, path, fh=None):
1174
1172
for k in key_list :
1175
1173
d = k .name .encode ('ascii' )[len (full_path ):]
1176
1174
if len (d ) > 0 :
1175
+ if d == '.' :
1176
+ continue # already there ### Do I need this ???
1177
1177
if d [- 1 ] == '/' :
1178
1178
d = d [:- 1 ]
1179
1179
dirs .append (d )
1180
1180
self .cache .set (path , 'readdir' , dirs )
1181
1181
1182
+ logger .debug ("readdir '%s' '%s' '%s'" % (path , fh , dirs ))
1182
1183
return dirs
1183
1184
1184
1185
def mkdir (self , path , mode ):
@@ -1210,13 +1211,14 @@ def mkdir(self, path, mode):
1210
1211
full_path = path + '/'
1211
1212
else :
1212
1213
full_path = path # To manage '/' with an empty s3_prefix
1213
- k .key = self .join_prefix (full_path )
1214
- logger .debug ("mkdir '%s' '%s' '%s' S3 " % (path , mode , k ))
1215
- k .set_contents_from_string ('' , headers = {'Content-Type' : 'application/x-directory' })
1214
+ if path != '/' or self .write_metadata :
1215
+ k .key = self .join_prefix (full_path )
1216
+ logger .debug ("mkdir '%s' '%s' '%s' S3 " % (path , mode , k ))
1217
+ k .set_contents_from_string ('' , headers = {'Content-Type' : 'application/x-directory' })
1216
1218
self .cache .set (path , 'key' , k )
1217
1219
data .delete ('change' )
1218
- self .cache .set (path , 'readdir' , ['.' , '..' ]) # the directory is empty
1219
1220
if path != '/' :
1221
+ self .cache .set (path , 'readdir' , ['.' , '..' ]) # the directory is empty
1220
1222
self .add_to_parent_readdir (path )
1221
1223
self .publish (['mkdir' , path ])
1222
1224
return 0
0 commit comments