mirror of
https://git.lyx.org/repos/lyx.git
synced 2025-01-21 23:09:40 +00:00
Fix part of 6587 - make backup more safe and delete autosave only after closing.
http://www.mail-archive.com/lyx-devel@lists.lyx.org/msg159029.html git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@33878 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
bd3f2308b4
commit
a59b92769f
@ -975,6 +975,17 @@ Buffer::ReadStatus Buffer::readFile(Lexer & lex, FileName const & filename,
|
||||
// Should probably be moved to somewhere else: BufferView? GuiView?
|
||||
bool Buffer::save() const
|
||||
{
|
||||
// ask if the disk file has been externally modified (use checksum method)
|
||||
if (fileName().exists() && isExternallyModified(checksum_method)) {
|
||||
docstring const file = makeDisplayPath(absFileName(), 20);
|
||||
docstring text = bformat(_("Document %1$s has been externally modified. Are you sure "
|
||||
"you want to overwrite this file?"), file);
|
||||
int const ret = Alert::prompt(_("Overwrite modified file?"),
|
||||
text, 1, 1, _("&Overwrite"), _("&Cancel"));
|
||||
if (ret == 1)
|
||||
return false;
|
||||
}
|
||||
|
||||
// We don't need autosaves in the immediate future. (Asger)
|
||||
resetAutosaveTimers();
|
||||
|
||||
@ -990,7 +1001,7 @@ bool Buffer::save() const
|
||||
backupName = FileName(addName(lyxrc.backupdir_path,
|
||||
mangledName));
|
||||
}
|
||||
if (fileName().copyTo(backupName)) {
|
||||
if (fileName().moveTo(backupName)) {
|
||||
madeBackup = true;
|
||||
} else {
|
||||
Alert::error(_("Backup failure"),
|
||||
@ -1001,17 +1012,6 @@ bool Buffer::save() const
|
||||
}
|
||||
}
|
||||
|
||||
// ask if the disk file has been externally modified (use checksum method)
|
||||
if (fileName().exists() && isExternallyModified(checksum_method)) {
|
||||
docstring const file = makeDisplayPath(absFileName(), 20);
|
||||
docstring text = bformat(_("Document %1$s has been externally modified. Are you sure "
|
||||
"you want to overwrite this file?"), file);
|
||||
int const ret = Alert::prompt(_("Overwrite modified file?"),
|
||||
text, 1, 1, _("&Overwrite"), _("&Cancel"));
|
||||
if (ret == 1)
|
||||
return false;
|
||||
}
|
||||
|
||||
if (writeFile(d->filename)) {
|
||||
markClean();
|
||||
return true;
|
||||
@ -1050,7 +1050,8 @@ bool Buffer::writeFile(FileName const & fname) const
|
||||
return false;
|
||||
}
|
||||
|
||||
removeAutosaveFile();
|
||||
// see bug 6587
|
||||
// removeAutosaveFile();
|
||||
|
||||
saveCheckSum(d->filename);
|
||||
message(str + _(" done."));
|
||||
|
@ -2304,6 +2304,7 @@ bool GuiView::closeBuffer(Buffer & buf)
|
||||
guiApp->gotoBookmark(i+1, false, false);
|
||||
|
||||
if (saveBufferIfNeeded(buf, false)) {
|
||||
buf.removeAutosaveFile();
|
||||
theBufferList().release(&buf);
|
||||
return true;
|
||||
}
|
||||
@ -2376,7 +2377,8 @@ bool GuiView::saveBufferIfNeeded(Buffer & buf, bool hiding)
|
||||
// if we crash after this we could
|
||||
// have no autosave file but I guess
|
||||
// this is really improbable (Jug)
|
||||
buf.removeAutosaveFile();
|
||||
// Sometime improbable things happen, bug 6857 (ps)
|
||||
// buf.removeAutosaveFile();
|
||||
if (hiding)
|
||||
// revert all changes
|
||||
buf.reload();
|
||||
|
Loading…
x
Reference in New Issue
Block a user