Ticket #1445: sugar-1445.patch

File sugar-1445.patch, 2.1 KB (added by alsroot, 15 years ago)
  • src/carquinyol/filestore.py

    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): 
    5252                except OSError, e:
    5353                    if e.errno == errno.EXDEV:
    5454                        self._async_copy(file_path, destination_path,
    55                                          completion_cb)
     55                                         completion_cb, unlink_src=True)
    5656                    else:
    5757                        raise
    5858            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)
    6061            """
    6162        TODO: How can we support deleting the file of an entry?
    6263        elif not file_path and os.path.exists(destination_path):
    class FileStore(object): 
    6869            logging.debug('FileStore: Nothing to do')
    6970            completion_cb()
    7071
    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):
    7274        """Start copying a file asynchronously.
    7375
    7476        """
     77        def copy_completion_cb(*args):
     78            if unlink_src:
     79                os.unlink(file_path)
     80            completion_cb(*args)
     81
    7582        logging.debug('FileStore copying from %r to %r', file_path,
    7683            destination_path)
    77         async_copy = AsyncCopy(file_path, destination_path, completion_cb)
     84        async_copy = AsyncCopy(file_path, destination_path,
     85                copy_completion_cb)
    7886        async_copy.start()
    7987
    8088    def retrieve(self, uid, user_id, extension):