From a7539317d4847a9eb9fe431709ddab23e54f4be3 Mon Sep 17 00:00:00 2001 From: Victor Shyba Date: Mon, 20 Mar 2017 21:37:20 -0300 Subject: [bug] create dirs before checking disk usage --- server/src/leap/soledad/server/_blobs.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'server/src/leap') diff --git a/server/src/leap/soledad/server/_blobs.py b/server/src/leap/soledad/server/_blobs.py index 4b0cd0de..c9b78005 100644 --- a/server/src/leap/soledad/server/_blobs.py +++ b/server/src/leap/soledad/server/_blobs.py @@ -120,7 +120,10 @@ class FilesystemBlobsBackend(object): def write_blob(self, user, blob_id, request): path = self._get_path(user, blob_id) - logger.info('writing blob: %s - %s' % (user, blob_id)) + try: + os.makedirs(os.path.split(path)[0]) + except: + pass if os.path.isfile(path): # XXX return some 5xx code raise BlobAlreadyExists() @@ -131,11 +134,7 @@ class FilesystemBlobsBackend(object): request.write('Quota Exceeded!') request.finish() return NOT_DONE_YET - try: - os.makedirs(os.path.split(path)[0]) - except: - pass - logger.debug("writing blob: %s" % path) + logger.info('writing blob: %s - %s' % (user, blob_id)) fbp = FileBodyProducer(request.content) d = fbp.startProducing(open(path, 'wb')) d.addCallback(lambda _: request.finish()) -- cgit v1.2.3