Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTomeu Vizoso <tomeu@tomeuvizoso.net>2008-09-10 15:22:43 (GMT)
committer Tomeu Vizoso <tomeu@tomeuvizoso.net>2008-09-10 15:22:43 (GMT)
commit280ecdefb00d4e20e4f64883c8bbd2fdd6f86ff5 (patch)
treeab72177dab6be2b766fec8a2e3ea3d851f705bd5
parent5d4d9f60286f433779bd02c735bdc1eb1a109e81 (diff)
Improve error reporting
-rw-r--r--src/olpc/datastore/filestore.py12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/olpc/datastore/filestore.py b/src/olpc/datastore/filestore.py
index 15b0185..797c4f9 100644
--- a/src/olpc/datastore/filestore.py
+++ b/src/olpc/datastore/filestore.py
@@ -19,9 +19,13 @@ class FileStore(object):
os.makedirs(dir_path)
destination_path = os.path.join(dir_path, uid)
- if os.path.exists(file_path):
+ if file_path:
+ if not os.path.isfile(file_path):
+ raise ValueError('No file at %r' % file_path)
if transfer_ownership:
try:
+ logging.debug('FileStore moving from %r to %r' % \
+ (file_path, destination_path))
os.rename(file_path, destination_path)
self._enqueue_checksum(uid)
completion_cb()
@@ -34,13 +38,17 @@ class FileStore(object):
else:
self._async_copy(uid, file_path, destination_path,
completion_cb)
- elif file_path == '' and os.path.exists(destination_path):
+ elif not file_path and os.path.exists(destination_path):
os.remove(destination_path)
completion_cb()
else:
+ logging.debug('FileStore moving from %r to %r' % \
+ (file_path, destination_path))
completion_cb()
def _async_copy(self, uid, file_path, destination_path, completion_cb):
+ logging.debug('FileStore copying from %r to %r' % \
+ (file_path, destination_path))
async_copy = AsyncCopy(file_path, destination_path,
lambda: self._async_copy_completion_cb(uid, completion_cb))
async_copy.start()