From 4ecd1314fd7bedf893f8998acccd0bd17ca81939 Mon Sep 17 00:00:00 2001 From: moculus Date: Tue, 24 Feb 2009 15:53:28 +0000 Subject: [PATCH] stupid mistake --HG-- branch : pmacs2 --- buffer/__init__.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/buffer/__init__.py b/buffer/__init__.py index bca58b3..bd9ce6e 100644 --- a/buffer/__init__.py +++ b/buffer/__init__.py @@ -659,8 +659,10 @@ class FileBuffer(Buffer): if self.changed_on_disk(): raise Exception, "oh no! %r has changed on-disk!" % self.path - temp_path = self._temp_path() - shutil.copyfile(self.path, temp_path) + exists = os.path.exists(self.path) + if exists: + temp_path = self._temp_path() + shutil.copyfile(self.path, temp_path) try: data = self.make_string() @@ -672,12 +674,12 @@ class FileBuffer(Buffer): f2.write(self.bytemark + data) f2.close() except: - shutil.copyfile(temp_path, self.path) + if exists: shutil.copyfile(temp_path, self.path) else: self.store_checksum(data) self.modified = False finally: - os.unlink(temp_path) + if exists: os.unlink(temp_path) def save_as(self, path): self.path = path self.save()