From: Enrico Forestieri Date: Sat, 10 Apr 2010 01:24:37 +0000 (+0000) Subject: Fix bug #2434: Child .tex document overwritten on latex export X-Git-Tag: 2.0.0~3496 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=833e358ffa3072d010e05d48e1d9630732a6f5c5;p=lyx.git Fix bug #2434: Child .tex document overwritten on latex export git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@34109 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/src/Exporter.cpp b/src/Exporter.cpp index 85d5eb3d55..f56209e37b 100644 --- a/src/Exporter.cpp +++ b/src/Exporter.cpp @@ -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;