Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/sugar_network/db/storage.py
diff options
context:
space:
mode:
Diffstat (limited to 'sugar_network/db/storage.py')
-rw-r--r--sugar_network/db/storage.py10
1 files changed, 6 insertions, 4 deletions
diff --git a/sugar_network/db/storage.py b/sugar_network/db/storage.py
index 83fb0c7..a280a13 100644
--- a/sugar_network/db/storage.py
+++ b/sugar_network/db/storage.py
@@ -135,14 +135,16 @@ class Record(object):
meta['mtime'] = int(os.stat(path).st_mtime)
return meta
- def set(self, prop, mtime=None, **meta):
+ def set(self, prop, mtime=None, cleanup_blob=False, blob=None, **meta):
if not exists(self._root):
os.makedirs(self._root)
meta_path = join(self._root, prop)
+ dst_blob_path = meta_path + _BLOB_SUFFIX
- if 'blob' in meta:
- dst_blob_path = meta_path + _BLOB_SUFFIX
- blob = meta.pop('blob')
+ if (cleanup_blob or blob is not None) and exists(dst_blob_path):
+ os.unlink(dst_blob_path)
+
+ if blob is not None:
if hasattr(blob, 'read'):
with toolkit.new_file(dst_blob_path) as f:
shutil.copyfileobj(blob, f)