Skip to content

Commit a07f238

Browse files
committed
Root directory ownership and permission fixed
1 parent bf2fcda commit a07f238

File tree

1 file changed

+24
-13
lines changed

1 file changed

+24
-13
lines changed

yas3fs.py

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1011,12 +1011,19 @@ def get_key(self, path, cache=True):
10111011
if cache:
10121012
key = self.cache.get(path, 'key')
10131013
if key:
1014+
logger.debug("get_key from cache '%s'" % (path))
10141015
return key
1016+
logger.debug("get_key from S3 #1 '%s'" % (path))
10151017
key = self.s3_bucket.get_key(self.join_prefix(path))
10161018
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))
10181022
if key:
1023+
logger.debug("get_key to cache '%s'" % (path))
10191024
self.cache.set(path, 'key', key)
1025+
else:
1026+
logger.debug("get_key no '%s'" % (path))
10201027
return key
10211028

10221029
def get_metadata(self, path, metadata_name, key=None):
@@ -1026,12 +1033,15 @@ def get_metadata(self, path, metadata_name, key=None):
10261033
key = self.get_key(path)
10271034
if not key:
10281035
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)
10321041
return self.cache.get(path, metadata_name)
10331042
else:
10341043
full_path = self.join_prefix(path + '/')
1044+
logger.debug("get_metadata -> '%s' '%s' '%s' S3 list '%s'" % (path, metadata_name, key, full_path))
10351045
key_list = self.s3_bucket.list(full_path) # Don't need to set a delimeter here
10361046
if len(list(key_list)) == 0:
10371047
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)
10921102
values = metadata_values
10931103
if values == None:
10941104
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
11001111
if (not data) or (data and (not data.has('change'))):
11011112
logger.debug("writing metadata '%s' '%s'" % (path, key))
11021113
md = key.metadata
11031114
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?
11051116
self.publish(['md', metadata_name, path])
11061117

11071118
def getattr(self, path, fh=None):
@@ -1995,7 +2006,7 @@ def main():
19952006
parser.add_option("-f", "--foreground", action="store_true", dest="foreground", default=False,
19962007
help="run in foreground")
19972008
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")
19992010

20002011
(options, args) = parser.parse_args()
20012012

@@ -2026,7 +2037,7 @@ def main():
20262037
if sys.platform == "darwin":
20272038
volume_name = os.path.basename(mountpoint)
20282039
fuse = FUSE(YAS3FS(options), mountpoint, fsname="yas3fs",
2029-
foreground=options.foreground or options.debug,
2040+
foreground=options.foreground,
20302041
default_permissions=True, allow_other=True,
20312042
auto_cache=True, atime=False,
20322043
max_read=131072, max_write=131072, max_readahead=131072,
@@ -2035,7 +2046,7 @@ def main():
20352046
# local=True) # local option is quite unstable
20362047
else:
20372048
fuse = FUSE(YAS3FS(options), mountpoint, fsname="yas3fs",
2038-
foreground=options.foreground or options.debug,
2049+
foreground=options.foreground,
20392050
default_permissions=True, allow_other=True,
20402051
auto_cache=True, atime=False,
20412052
big_writes=True, # Not working on OS X

0 commit comments

Comments
 (0)