From 365a2daf53199a50497a55359270e259882c514b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrgen=20Spitzm=C3=BCller?= Date: Tue, 8 Aug 2006 14:39:08 +0000 Subject: [PATCH] Prevent boost::filesystem assert (w/ dataloss) when the backup dir was invalid or not writeable. War the user instead and skip backup (bug 2740) git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/branches/BRANCH_1_4_X@14576 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/ChangeLog | 6 ++++++ src/buffer.C | 10 +++++++++- status.14x | 3 +++ 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/ChangeLog b/src/ChangeLog index cfe1d55e42..889cb344b0 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,9 @@ +2006-08-08 Jürgen Spitzmüller + + * buffer.C (save): Check if the backup directory is valid and + writeable, and warn the user if not (instead of letting boost + assert) [bug 2740]. + 2006-08-08 Georg Baum * LaTeX.C (deplog): Add the toc file to the dependencies if a line diff --git a/src/buffer.C b/src/buffer.C index 0768c8add2..13648396b9 100644 --- a/src/buffer.C +++ b/src/buffer.C @@ -701,7 +701,10 @@ bool Buffer::save() const // good enough. (Lgb) // But to use this we need fs::copy_file to actually do a copy, // even when the target file exists. (Lgb) - if (fs::exists(fileName()) && fs::is_writable(fs::path(fileName()).branch_path())) { + if (fs::exists(fileName()) + && fs::is_writable(fs::path(fileName()).branch_path()) + && fs::exists(fs::path(s).branch_path()) + && fs::is_writable(fs::path(s).branch_path())) { //try { fs::copy_file(fileName(), s, false); //} @@ -709,6 +712,11 @@ bool Buffer::save() const //lyxerr << "LyX was not able to make backup copy. Beware.\n" // << fe.what() << endl; //} + } else { + Alert::error(_("Backup failure"), + bformat(_("LyX was not able to make a backup copy in %1$s.\n" + "Please check if the directory exists and is writeable."), + fs::path(s).branch_path().native_directory_string())); } } diff --git a/status.14x b/status.14x index 9928f7ee23..d1af6f695e 100644 --- a/status.14x +++ b/status.14x @@ -26,6 +26,9 @@ What's new * Document Input/Output +- Fix crash on save (including dataloss) when the backup directory + was invalid or not writeable(bug 2740). + - Fix crash when importing LaTeX files with no text (bug 2667) - Ignore definition of lyxgreyout environment when re-importing a LyX