Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/src/carquinyol/filestore.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/carquinyol/filestore.py')
-rw-r--r--src/carquinyol/filestore.py23
1 files changed, 13 insertions, 10 deletions
diff --git a/src/carquinyol/filestore.py b/src/carquinyol/filestore.py
index f88c531..b96c323 100644
--- a/src/carquinyol/filestore.py
+++ b/src/carquinyol/filestore.py
@@ -23,15 +23,17 @@ import gobject
from carquinyol import layoutmanager
+
class FileStore(object):
"""Handle the storage of one file per entry.
"""
+
# TODO: add protection against store and retrieve operations on entries
# that are being processed async.
def store(self, uid, file_path, transfer_ownership, completion_cb):
"""Store a file for a given entry.
-
+
"""
dir_path = layoutmanager.get_instance().get_entry_path(uid)
if not os.path.exists(dir_path):
@@ -68,7 +70,7 @@ class FileStore(object):
def _async_copy(self, file_path, destination_path, completion_cb):
"""Start copying a file asynchronously.
-
+
"""
logging.debug('FileStore copying from %r to %r' % \
(file_path, destination_path))
@@ -76,9 +78,10 @@ class FileStore(object):
async_copy.start()
def retrieve(self, uid, user_id, extension):
- """Place the file associated to a given entry into a directory where the
- user can read it. The caller is reponsible for deleting this file.
-
+ """Place the file associated to a given entry into a directory
+ where the user can read it. The caller is reponsible for
+ deleting this file.
+
"""
dir_path = layoutmanager.get_instance().get_entry_path(uid)
file_path = os.path.join(dir_path, 'data')
@@ -91,8 +94,8 @@ class FileStore(object):
if use_instance_dir:
if not user_id:
raise ValueError('Couldnt determine the current user uid.')
- destination_dir = os.path.join(os.environ['HOME'], 'isolation', '1',
- 'uid_to_instance_dir', str(user_id))
+ destination_dir = os.path.join(os.environ['HOME'], 'isolation',
+ '1', 'uid_to_instance_dir', str(user_id))
else:
profile = os.environ.get('SUGAR_PROFILE', 'default')
destination_dir = os.path.join(os.path.expanduser('~'), '.sugar',
@@ -147,7 +150,7 @@ class FileStore(object):
def delete(self, uid):
"""Remove the file associated to a given entry.
-
+
"""
dir_path = layoutmanager.get_instance().get_entry_path(uid)
file_path = os.path.join(dir_path, 'data')
@@ -168,9 +171,10 @@ class FileStore(object):
logging.debug('hard linking %r -> %r' % (new_file, existing_file))
os.link(existing_file, new_file)
+
class AsyncCopy(object):
"""Copy a file in chunks in the idle loop.
-
+
"""
CHUNK_SIZE = 65536
@@ -227,4 +231,3 @@ class AsyncCopy(object):
self.size = stat[6]
gobject.idle_add(self._copy_block)
-