Skip to content

Commit

Permalink
Move/rename dirs now works recoursively to keep the cache updated.
Browse files Browse the repository at this point in the history
  • Loading branch information
danilop committed Jun 17, 2014
1 parent be2adb2 commit c815bb5
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions yas3fs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1231,8 +1231,8 @@ def get_key(self, path, cache=True):
key = self.s3_bucket.get_key(self.join_prefix(full_path), headers=self.default_headers)
if key:
logger.debug("get_key to cache '%s'" % (path))
self.cache.delete(path)
self.cache.add(path)
###self.cache.delete(path) ### ???
###self.cache.add(path)
self.cache.set(path, 'key', key)

if refresh_readdir_cache_if_found:
Expand Down Expand Up @@ -1296,8 +1296,7 @@ def get_metadata(self, path, metadata_name, key=None):
metadata_values['st_uid'] = uid
metadata_values['st_gid'] = gid
if key == None:
### # no key, default to empty file
### metadata_values['st_mode'] = (stat.S_IFREG | 0755)
### # no key, default to dir
metadata_values['st_mode'] = (stat.S_IFDIR | 0755)
elif key and key.name != '' and key.name[-1] != '/':
metadata_values['st_mode'] = (stat.S_IFREG | 0755)
Expand Down Expand Up @@ -1909,8 +1908,7 @@ def rename(self, path, new_path):
if not new_parent_key and not self.folder_has_contents(new_parent_path):
logger.debug("rename '%s' '%s' ENOENT no parent path '%s'" % (path, new_path, new_parent_path))
raise FuseOSError(errno.ENOENT)
to_copy = {}
attr = self.getattr(path)
attr = self.getattr(path) xxx
if stat.S_ISDIR(attr['st_mode']):
self.rename_path(path, new_path)
else:
Expand All @@ -1925,7 +1923,7 @@ def rename_path(self, path, new_path):
if d in ['.', '..']:
continue
d_path = ''.join(path, '/', d)
d_new_path = ''.join([new_path, '/', os.path.basename(path)])
d_new_path = ''.join([new_path, '/', os.path.basename(path), d])
attr = self.getattr(d_path)
if stat.S_ISDIR(attr['st_mode']):
self.rename_path(d_path, d_new_path)
Expand All @@ -1944,6 +1942,7 @@ def rename_item(self, path, new_path, dir=False):
self.rename_on_s3(key, source_path, target_path, dir)

def rename_on_s3(self, key, source_path, target_path, dir):
logger.debug("rename_on_s3 '%s' '%s' -> '%s' dir?%s" % (key, source_path, target_path, dir))
# Otherwise we loose the Content-Type with S3 Copy
key.metadata['Content-Type'] = key.content_type
### key.copy(key.bucket.name, target, key.metadata, preserve_acl=False)
Expand Down

0 comments on commit c815bb5

Please sign in to comment.