parent
d5ac811eda
commit
4ecd1314fd
|
@ -659,8 +659,10 @@ class FileBuffer(Buffer):
|
||||||
if self.changed_on_disk():
|
if self.changed_on_disk():
|
||||||
raise Exception, "oh no! %r has changed on-disk!" % self.path
|
raise Exception, "oh no! %r has changed on-disk!" % self.path
|
||||||
|
|
||||||
temp_path = self._temp_path()
|
exists = os.path.exists(self.path)
|
||||||
shutil.copyfile(self.path, temp_path)
|
if exists:
|
||||||
|
temp_path = self._temp_path()
|
||||||
|
shutil.copyfile(self.path, temp_path)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
data = self.make_string()
|
data = self.make_string()
|
||||||
|
@ -672,12 +674,12 @@ class FileBuffer(Buffer):
|
||||||
f2.write(self.bytemark + data)
|
f2.write(self.bytemark + data)
|
||||||
f2.close()
|
f2.close()
|
||||||
except:
|
except:
|
||||||
shutil.copyfile(temp_path, self.path)
|
if exists: shutil.copyfile(temp_path, self.path)
|
||||||
else:
|
else:
|
||||||
self.store_checksum(data)
|
self.store_checksum(data)
|
||||||
self.modified = False
|
self.modified = False
|
||||||
finally:
|
finally:
|
||||||
os.unlink(temp_path)
|
if exists: os.unlink(temp_path)
|
||||||
def save_as(self, path):
|
def save_as(self, path):
|
||||||
self.path = path
|
self.path = path
|
||||||
self.save()
|
self.save()
|
||||||
|
|
Loading…
Reference in New Issue