]> git.lyx.org Git - features.git/commitdiff
Use a different naming scheme, per Enrico's suggestion.
authorRichard Heck <rgheck@lyx.org>
Wed, 4 Jun 2014 16:46:42 +0000 (12:46 -0400)
committerRichard Heck <rgheck@lyx.org>
Wed, 4 Jun 2014 16:47:37 +0000 (12:47 -0400)
(cherry picked from commit 533a05e0b8e3433cdea2c239700904406b9b683e)

src/Buffer.cpp

index 8fab72d82ac3aef960252e301f263989284dbbad..867eddd3625219ebea83fe84053ba7321ae49541 100644 (file)
@@ -1285,10 +1285,13 @@ bool Buffer::save() const
        // proper location once that has been done successfully. that
        // way we preserve the original file if something goes wrong.
        string const savepath = fileName().onlyPath().absFileName();
-       string savename = "tmp-" + fileName().onlyFileName();
+       int fnum = 1;
+       string const fname = fileName().onlyFileName();
+       string savename = "tmp-" + convert<string>(fnum) + "-" + fname;
        FileName savefile(addName(savepath, savename));
        while (savefile.exists()) {
-               if (savefile.absFileName().size() > 1024) {
+               // surely that is enough tries?
+               if (fnum > 100) {
                        Alert::error(_("Write failure"),
                                     bformat(_("Cannot find temporary filename for:\n  %1$s.\n"
                                         "Even %2$s exists!"),
@@ -1296,7 +1299,8 @@ bool Buffer::save() const
                                 from_utf8(savefile.absFileName())));
                        return false;
                }
-               savename = "tmp-" + savename;
+               fnum += 1;
+               savename = "tmp-" + convert<string>(fnum) + "-" + fname;
                savefile.set(addName(savepath, savename));
        }