From ad9244e31184415e73be075e9ace053fca97d2f5 Mon Sep 17 00:00:00 2001 From: Sascha Silbe Date: Sun, 06 Mar 2011 01:26:36 +0000 Subject: don't destroy unchanged data store entries (SL#2668) Calling datastore.get() and passing the file name back into datastore.update() for the same entry with transfer_ownership set to False destroyed the data file. This was because source and destination file are identical (hard links) and we overwrote the destination file in AsyncCopy.start() without unlinking it first. Fix this by unlinking the destination file if it exists. Reported-By: Daniel Drake Signed-off-by: Sascha Silbe Acked-by: Simon Schampijer --- diff --git a/src/carquinyol/filestore.py b/src/carquinyol/filestore.py index 5f518ab..7094310 100644 --- a/src/carquinyol/filestore.py +++ b/src/carquinyol/filestore.py @@ -221,6 +221,9 @@ class AsyncCopy(object): self.completion(*args) def start(self): + if os.path.exists(self.dest): + os.unlink(self.dest) + self.src_fp = os.open(self.src, os.O_RDONLY) self.dest_fp = os.open(self.dest, os.O_RDWR | os.O_TRUNC | os.O_CREAT, 0644) -- cgit v0.9.1