mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-24 21:55:29 +00:00
* src/buffer.C (save):
catch exception thrown by boost::filesystem if copying to the backup directory fails (fixes bug 2740: crash and dataloss if the backup dir was invalid or not writeable). git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@14849 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
3dca656ae4
commit
16b150e6bf
17
src/buffer.C
17
src/buffer.C
@ -78,6 +78,7 @@ namespace io = boost::iostreams;
|
|||||||
#include "support/convert.h"
|
#include "support/convert.h"
|
||||||
|
|
||||||
#include <boost/bind.hpp>
|
#include <boost/bind.hpp>
|
||||||
|
#include <boost/filesystem/exception.hpp>
|
||||||
#include <boost/filesystem/operations.hpp>
|
#include <boost/filesystem/operations.hpp>
|
||||||
|
|
||||||
#if defined (HAVE_UTIME_H)
|
#if defined (HAVE_UTIME_H)
|
||||||
@ -712,14 +713,16 @@ bool Buffer::save() const
|
|||||||
// good enough. (Lgb)
|
// good enough. (Lgb)
|
||||||
// But to use this we need fs::copy_file to actually do a copy,
|
// But to use this we need fs::copy_file to actually do a copy,
|
||||||
// even when the target file exists. (Lgb)
|
// even when the target file exists. (Lgb)
|
||||||
if (fs::exists(fileName()) && fs::is_writable(fs::path(fileName()).branch_path())) {
|
try {
|
||||||
//try {
|
|
||||||
fs::copy_file(fileName(), s, false);
|
fs::copy_file(fileName(), s, false);
|
||||||
//}
|
}
|
||||||
//catch (fs::filesystem_error const & fe) {
|
catch (fs::filesystem_error const & fe) {
|
||||||
//lyxerr << "LyX was not able to make backup copy. Beware.\n"
|
Alert::error(_("Backup failure"),
|
||||||
// << fe.what() << endl;
|
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()));
|
||||||
|
lyxerr[Debug::DEBUG] << "Fs error: "
|
||||||
|
<< fe.what() << endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user