From b7522c44d6291875e4430b6cfdcb217f3c1de736 Mon Sep 17 00:00:00 2001
From: Aleksey Lim <alsroot@member.fsf.org>
Date: Thu, 1 Oct 2009 13:47:49 +0000
Subject: Screenshot file is not deleted #1445
---
src/carquinyol/filestore.py | 16 ++++++++++++----
1 files changed, 12 insertions(+), 4 deletions(-)
diff --git a/src/carquinyol/filestore.py b/src/carquinyol/filestore.py
index 71d6344..d63fdf3 100644
a
|
b
|
class FileStore(object): |
52 | 52 | except OSError, e: |
53 | 53 | if e.errno == errno.EXDEV: |
54 | 54 | self._async_copy(file_path, destination_path, |
55 | | completion_cb) |
| 55 | completion_cb, unlink_src=True) |
56 | 56 | else: |
57 | 57 | raise |
58 | 58 | else: |
59 | | self._async_copy(file_path, destination_path, completion_cb) |
| 59 | self._async_copy(file_path, destination_path, completion_cb, |
| 60 | unlink_src=False) |
60 | 61 | """ |
61 | 62 | TODO: How can we support deleting the file of an entry? |
62 | 63 | elif not file_path and os.path.exists(destination_path): |
… |
… |
class FileStore(object): |
68 | 69 | logging.debug('FileStore: Nothing to do') |
69 | 70 | completion_cb() |
70 | 71 | |
71 | | def _async_copy(self, file_path, destination_path, completion_cb): |
| 72 | def _async_copy(self, file_path, destination_path, completion_cb, |
| 73 | unlink_src): |
72 | 74 | """Start copying a file asynchronously. |
73 | 75 | |
74 | 76 | """ |
| 77 | def copy_completion_cb(*args): |
| 78 | if unlink_src: |
| 79 | os.unlink(file_path) |
| 80 | completion_cb(*args) |
| 81 | |
75 | 82 | logging.debug('FileStore copying from %r to %r', file_path, |
76 | 83 | destination_path) |
77 | | async_copy = AsyncCopy(file_path, destination_path, completion_cb) |
| 84 | async_copy = AsyncCopy(file_path, destination_path, |
| 85 | copy_completion_cb) |
78 | 86 | async_copy.start() |
79 | 87 | |
80 | 88 | def retrieve(self, uid, user_id, extension): |