Skip to content

Commit

Permalink
Writeback works with deleted/rename keys.
Browse files Browse the repository at this point in the history
  • Loading branch information
danilop committed May 19, 2014
1 parent ad9b3d5 commit 7d12f96
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 10 deletions.
31 changes: 22 additions & 9 deletions yas3fs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,7 @@ def rename(self, path, new_path):
self.lru.append(new_path)
self.lru.delete(path)
del self.entries[path]
self.reset(path) # I need 'deleted'
def get(self, path, prop=None):
self.lru.move_to_the_tail(path) # Move to the tail of the LRU cache
try:
Expand All @@ -413,6 +414,7 @@ def reset(self, path):
with self.get_lock(path):
self.delete(path)
self.add(path)
self.set(path, 'deleted', True)
def has(self, path, prop=None):
self.lru.move_to_the_tail(path) # Move to the tail of the LRU cache
if prop == None:
Expand All @@ -423,15 +425,23 @@ def has(self, path, prop=None):
except KeyError:
return False
def is_empty(self, path): # To improve readability
try:
return len(self.get(path)) <= 1 # Empty or just with 'lock'
except TypeError: # if get returns None
return False
if self.has(path) and not self.has(path, 'attr'):
return True
else:
return False
###try:
### return len(self.get(path)) <= 1 # Empty or just with 'lock'
###except TypeError: # if get returns None
### return False
def is_not_empty(self, path): # To improve readability
try:
return len(self.get(path)) > 1 # More than just 'lock'
except TypeError: # if get returns None
return False
if self.has(path) and self.has(path, 'attr'):
return True
else:
return False
###try:
### return len(self.get(path)) > 1 # More than just 'lock'
###except TypeError: # if get returns None
### return False

class SNS_HTTPServer(BaseHTTPServer.HTTPServer):
""" HTTP Server to receive SNS notifications via HTTP """
Expand Down Expand Up @@ -1141,6 +1151,9 @@ def folder_has_contents(self, path, num=1):

def get_key(self, path, cache=True):
if cache:
if self.cache.has(path, 'deleted'):
logger.debug("get_key from cache deleted '%s'" % (path))
return None
key = self.cache.get(path, 'key')
if key:
logger.debug("get_key from cache '%s'" % (path))
Expand Down Expand Up @@ -1198,7 +1211,7 @@ def get_metadata(self, path, metadata_name, key=None):
if s:
try:
metadata_values = json.loads(s)
except ValueError: # For legacy atrribute encoding
except ValueError: # For legacy attribute encoding
for kv in s.split(';'):
k, v = kv.split('=')
if v.isdigit():
Expand Down
2 changes: 1 addition & 1 deletion yas3fs/_version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '2.2.8'
__version__ = '2.2.9'

0 comments on commit 7d12f96

Please sign in to comment.