Bug 1207364 - Saving near identical group of emails (same subject, date and time) should only append one increasing number to the .eml file name. r=mkmelin a=Aryx
authorSebastian Hengst <archaeopteryx@coole-files.de>
Sun, 27 Sep 2015 18:19:02 +0200
changeset 18446 0a2d1cf589572b1fdbdaff2c9aeb395da24cfdc7
parent 18445 e2c24386c86ada758bdb5c3f0c2b3f2c8c090512
child 18447 306b67ce6ad9ea4ac54c64a3a98f5b8da01e0081
push id11294
push userarchaeopteryx@coole-files.de
push dateSun, 27 Sep 2015 16:20:11 +0000
treeherdercomm-central@0a2d1cf58957 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmkmelin, Aryx
bugs1207364
Bug 1207364 - Saving near identical group of emails (same subject, date and time) should only append one increasing number to the .eml file name. r=mkmelin a=Aryx New behavior for duplicates to the generated filenames: filename.eml filename-2.eml filename-3.eml Old behavior was: filename.eml filename-2.eml filename-2-3.eml
mail/base/content/mailCommands.js
--- a/mail/base/content/mailCommands.js
+++ b/mail/base/content/mailCommands.js
@@ -353,21 +353,22 @@ function SaveAsFile(uris)
     messenger.saveAs(uri, true, null, filename);
   }
   else {
     let filenames = [];
     for (let i = 0; i < uris.length; i++) {
       let msgHdr = messenger.messageServiceFromURI(uris[i])
                             .messageURIToMsgHdr(uris[i]);
 
-      let name = GenerateFilenameFromMsgHdr(msgHdr);
-      name = GenerateValidFilename(name, ".eml");
+      let nameBase = GenerateFilenameFromMsgHdr(msgHdr);
+      let name = GenerateValidFilename(nameBase, ".eml");
+      
       let number = 2;
       while (filenames.includes(name)) { // should be unlikely
-        name = name.substring(0, name.length - 4) + "-" + number + ".eml";
+        name = GenerateValidFilename(nameBase + "-" + number, ".eml");
         number++;
       }
       filenames.push(name);
     }
     messenger.saveMessages(uris.length, filenames, uris);
   }
 }