]> git.lyx.org Git - features.git/commitdiff
First part of http://bugzilla.lyx.org/show_bug.cgi?id=4918
authorAbdelrazak Younes <younes@lyx.org>
Mon, 9 Jun 2008 09:34:11 +0000 (09:34 +0000)
committerAbdelrazak Younes <younes@lyx.org>
Mon, 9 Jun 2008 09:34:11 +0000 (09:34 +0000)
Prevent deletion of LyX temporary directory is this is not a LyX created directory.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@25199 a592a061-630c-0410-9148-cb99ea01b6c8

src/LyX.cpp

index ed841793462149ca012a6525d5dac75b64106863..2c8f766c72038c6989b30282dcb313fac0d46ebf 100644 (file)
@@ -463,14 +463,21 @@ void LyX::prepareExit()
 
        // do any other cleanup procedures now
        if (package().temp_dir() != package().system_temp_dir()) {
-               LYXERR(Debug::INFO, "Deleting tmp dir "
-                                   << package().temp_dir().absFilename());
-
-               if (!package().temp_dir().destroyDirectory()) {
+               string const abs_tmpdir = package().temp_dir().absFilename();
+               if (!contains(package().temp_dir().absFilename(), "lyx_tmpdir")) {
                        docstring const msg =
-                               bformat(_("Unable to remove the temporary directory %1$s"),
-                               from_utf8(package().temp_dir().absFilename()));
-                       Alert::warning(_("Unable to remove temporary directory"), msg);
+                               bformat(_("%1$s does not appear like a LyX created temporary directory."),
+                               from_utf8(abs_tmpdir));
+                       Alert::warning(_("Cannot remove temporary directory"), msg);
+               } else {
+                       LYXERR(Debug::INFO, "Deleting tmp dir "
+                               << package().temp_dir().absFilename());
+                       if (!package().temp_dir().destroyDirectory()) {
+                               docstring const msg =
+                                       bformat(_("Unable to remove the temporary directory %1$s"),
+                                       from_utf8(package().temp_dir().absFilename()));
+                               Alert::warning(_("Unable to remove temporary directory"), msg);
+                       }
                }
        }