]> git.lyx.org Git - lyx.git/commitdiff
Fix bug #2434: Child .tex document overwritten on latex export
authorEnrico Forestieri <forenr@lyx.org>
Sat, 10 Apr 2010 01:24:37 +0000 (01:24 +0000)
committerEnrico Forestieri <forenr@lyx.org>
Sat, 10 Apr 2010 01:24:37 +0000 (01:24 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@34109 a592a061-630c-0410-9148-cb99ea01b6c8

src/Exporter.cpp

index 85d5eb3d5551862f7791fc21897651da4124a5bc..f56209e37ba9b70a2ed31bf0e718f44958eaff09 100644 (file)
@@ -36,18 +36,23 @@ namespace lyx {
 
 namespace Alert = frontend::Alert;
 
-/// ask the user what to do if a file already exists
-static int checkOverwrite(FileName const & filename)
+/// Ask the user what to do if the destination file already exists
+/// and is different from the source file.
+static int checkOverwrite(FileName const & src_file, FileName const & dst_file)
 {
-       if (!filename.exists())
+       if (!dst_file.exists())
                return 0;
+
+       if (src_file.checksum() == dst_file.checksum())
+               return -1;
+
        docstring text = bformat(_("The file %1$s already exists.\n\n"
-                                                        "Do you want to overwrite that file?"),
-                                               makeDisplayPath(filename.absFilename()));
+                                  "Do you want to overwrite that file?"),
+                                  makeDisplayPath(dst_file.absFilename()));
        return Alert::prompt(_("Overwrite file?"),
-                                        text, 0, 2,
-                                        _("&Overwrite"), _("Overwrite &all"),
-                                        _("&Cancel export"));
+                               text, 0, 2,
+                               _("&Overwrite"), _("Overwrite &all"),
+                               _("&Cancel export"));
 }
 
 
@@ -73,7 +78,9 @@ CopyStatus copyFile(string const & format,
                return ret;
 
        if (!force) {
-               switch(checkOverwrite(destFile)) {
+               switch(checkOverwrite(sourceFile, destFile)) {
+               case -1:
+                       return SUCCESS;
                case 0:
                        ret = SUCCESS;
                        break;