]> git.lyx.org Git - features.git/commitdiff
.lyx as symlinks killed when saving because of #6587 workarounds.
authorPavel Sanda <sanda@lyx.org>
Fri, 28 Jan 2011 12:39:50 +0000 (12:39 +0000)
committerPavel Sanda <sanda@lyx.org>
Fri, 28 Jan 2011 12:39:50 +0000 (12:39 +0000)
At the end escape for fsync would be the least hackish solution
but it needs somebody with ext4 to test with.

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

src/Buffer.cpp

index f9545e4f40a5c3a541b90233fbc3083f2ce4632a..b4e03b99d08e2385b450c53b6955d2245d3b6d8a 100644 (file)
@@ -1055,10 +1055,15 @@ bool Buffer::save() const
                        backupName = FileName(addName(lyxrc.backupdir_path,
                                                      mangledName));
                }
-               // do not copy because of #6587
-               if (fileName().moveTo(backupName)) {
-                       madeBackup = true;
-               } else {
+
+               // Except file is symlink do not copy because of #6587.
+               // Hard links have bad luck.
+               if (fileName().isSymLink())
+                       madeBackup = fileName().copyTo(backupName);
+               else
+                       madeBackup = fileName().moveTo(backupName);
+
+               if (!madeBackup) {
                        Alert::error(_("Backup failure"),
                                     bformat(_("Cannot create backup file %1$s.\n"
                                               "Please check whether the directory exists and is writable."),