[Core] (Partially?) Fix data loss on dir rename (#4996)
* Fix lost filename in err msg In some circumstances, FileExceptions are constructed empty, then have a filename assigned to them, but the error message in these scenarios is left as the default "unknown" one, which is sometimes shown to users. This change fixes that case to be consistent with instances that are constructed with the filename. The exception can happen when trying to save the file in a location that does not exist, or when the user does not have permission to write there. If it comes when saving after closing the document, all previous changes can be lost. Partially fixes issue #4098. Co-authored-by: Heewa Barfchin <heewa.b@gmail.com>
This commit is contained in:
@@ -66,6 +66,7 @@ recompute path. Also, it enables more complicated dependencies beyond trees.
|
||||
# include <climits>
|
||||
# include <bitset>
|
||||
# include <random>
|
||||
# include <boost/filesystem.hpp>
|
||||
#endif
|
||||
|
||||
#include <boost/algorithm/string.hpp>
|
||||
@@ -142,6 +143,8 @@ using namespace zipios;
|
||||
# define FC_LOGFEATUREUPDATE
|
||||
#endif
|
||||
|
||||
namespace fs = boost::filesystem;
|
||||
|
||||
// typedef boost::property<boost::vertex_root_t, DocumentObject* > VertexProperty;
|
||||
typedef boost::adjacency_list <
|
||||
boost::vecS, // class OutEdgeListS : a Sequence or an AssociativeContainer
|
||||
@@ -2610,6 +2613,8 @@ bool Document::saveToFile(const char* filename) const
|
||||
fn += uuid;
|
||||
}
|
||||
Base::FileInfo tmp(fn);
|
||||
// In case some folders in the path do not exist
|
||||
fs::create_directories(fs::path(filename).parent_path());
|
||||
|
||||
// open extra scope to close ZipWriter properly
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user