stupid mistake

--HG--
branch : pmacs2
This commit is contained in:
moculus 2009-02-24 15:53:28 +00:00
parent d5ac811eda
commit 4ecd1314fd
1 changed files with 6 additions and 4 deletions

View File

@ -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()