@@ -1011,12 +1011,19 @@ def get_key(self, path, cache=True):
1011
1011
if cache :
1012
1012
key = self .cache .get (path , 'key' )
1013
1013
if key :
1014
+ logger .debug ("get_key from cache '%s'" % (path ))
1014
1015
return key
1016
+ logger .debug ("get_key from S3 #1 '%s'" % (path ))
1015
1017
key = self .s3_bucket .get_key (self .join_prefix (path ))
1016
1018
if not key :
1017
- key = self .s3_bucket .get_key (self .join_prefix (path + '/' ))
1019
+ full_path = path + '/'
1020
+ logger .debug ("get_key from S3 #2 '%s' '%s'" % (path , full_path ))
1021
+ key = self .s3_bucket .get_key (self .join_prefix (full_path ))
1018
1022
if key :
1023
+ logger .debug ("get_key to cache '%s'" % (path ))
1019
1024
self .cache .set (path , 'key' , key )
1025
+ else :
1026
+ logger .debug ("get_key no '%s'" % (path ))
1020
1027
return key
1021
1028
1022
1029
def get_metadata (self , path , metadata_name , key = None ):
@@ -1026,12 +1033,15 @@ def get_metadata(self, path, metadata_name, key=None):
1026
1033
key = self .get_key (path )
1027
1034
if not key :
1028
1035
if path == '/' : # First time mount of a new file system
1029
- self .cache .delete (path )
1030
- self .mkdir ('' , 0755 )
1031
- self .cache .rename ('' , path )
1036
+ ###self.cache.delete(path)
1037
+ ###self.mkdir('', 0755)
1038
+ #self.cache.rename('', path)
1039
+ logger .debug ("get_metadata -> '%s' '%s' '%s' First time mount" % (path , metadata_name , key ))
1040
+ self .mkdir (path , 0755 )
1032
1041
return self .cache .get (path , metadata_name )
1033
1042
else :
1034
1043
full_path = self .join_prefix (path + '/' )
1044
+ logger .debug ("get_metadata -> '%s' '%s' '%s' S3 list '%s'" % (path , metadata_name , key , full_path ))
1035
1045
key_list = self .s3_bucket .list (full_path ) # Don't need to set a delimeter here
1036
1046
if len (list (key_list )) == 0 :
1037
1047
self .cache .add (path ) # It is empty to cache further checks
@@ -1092,16 +1102,17 @@ def set_metadata(self, path, metadata_name=None, metadata_values=None, key=None)
1092
1102
values = metadata_values
1093
1103
if values == None :
1094
1104
values = self .cache .get (path , metadata_name )
1095
- s = ';' .join (['%s=%s' % (k ,v ) for k ,v in values .iteritems ()
1096
- if not (metadata_name == 'attr' and k == 'st_size' )]) # For the size use the key.size
1097
- key .metadata [metadata_name ] = s
1098
- elif metadata_name in key .metadata :
1099
- del key .metadata [metadata_name ]
1105
+ if values == None :
1106
+ del key .metadata [metadata_name ]
1107
+ else :
1108
+ s = ';' .join (['%s=%s' % (k ,v ) for k ,v in values .iteritems ()
1109
+ if not (metadata_name == 'attr' and k == 'st_size' )]) # For the size use the key.size
1110
+ key .metadata [metadata_name ] = s
1100
1111
if (not data ) or (data and (not data .has ('change' ))):
1101
1112
logger .debug ("writing metadata '%s' '%s'" % (path , key ))
1102
1113
md = key .metadata
1103
1114
md ['Content-Type' ] = key .content_type # Otherwise we loose the Content-Type with Copy
1104
- key .copy (key .bucket .name , key .name , md , preserve_acl = False ) # Do I need to preserve ACL?
1115
+ key .copy (key .bucket .name , key .name , md , preserve_acl = True ) # Do I need to preserve ACL?
1105
1116
self .publish (['md' , metadata_name , path ])
1106
1117
1107
1118
def getattr (self , path , fh = None ):
@@ -1995,7 +2006,7 @@ def main():
1995
2006
parser .add_option ("-f" , "--foreground" , action = "store_true" , dest = "foreground" , default = False ,
1996
2007
help = "run in foreground" )
1997
2008
parser .add_option ("-d" , "--debug" , action = "store_true" , dest = "debug" , default = False ,
1998
- help = "print debug information (implies '-f') " )
2009
+ help = "print debug information in log " )
1999
2010
2000
2011
(options , args ) = parser .parse_args ()
2001
2012
@@ -2026,7 +2037,7 @@ def main():
2026
2037
if sys .platform == "darwin" :
2027
2038
volume_name = os .path .basename (mountpoint )
2028
2039
fuse = FUSE (YAS3FS (options ), mountpoint , fsname = "yas3fs" ,
2029
- foreground = options .foreground or options . debug ,
2040
+ foreground = options .foreground ,
2030
2041
default_permissions = True , allow_other = True ,
2031
2042
auto_cache = True , atime = False ,
2032
2043
max_read = 131072 , max_write = 131072 , max_readahead = 131072 ,
@@ -2035,7 +2046,7 @@ def main():
2035
2046
# local=True) # local option is quite unstable
2036
2047
else :
2037
2048
fuse = FUSE (YAS3FS (options ), mountpoint , fsname = "yas3fs" ,
2038
- foreground = options .foreground or options . debug ,
2049
+ foreground = options .foreground ,
2039
2050
default_permissions = True , allow_other = True ,
2040
2051
auto_cache = True , atime = False ,
2041
2052
big_writes = True , # Not working on OS X
0 commit comments