diff options
author | Sascha Silbe <silbe@activitycentral.com> | 2011-03-06 01:26:36 (GMT) |
---|---|---|
committer | Sascha Silbe <silbe@activitycentral.com> | 2011-03-31 13:06:44 (GMT) |
commit | ad9244e31184415e73be075e9ace053fca97d2f5 (patch) | |
tree | 8750e8f6f58f24ba600237fc39b9290f4443425e | |
parent | b8275bca38e6cd57b96cec6724cf86bbee7a6a51 (diff) |
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 <dsd@laptop.org>
Signed-off-by: Sascha Silbe <silbe@activitycentral.com>
Acked-by: Simon Schampijer <simon@laptop.org>
-rw-r--r-- | src/carquinyol/filestore.py | 3 |
1 files changed, 3 insertions, 0 deletions
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) |