When renaming attachment files, keep file extension if not provided
This commit is contained in:
parent
64fb9efa76
commit
59ef7cba04
1 changed files with 9 additions and 3 deletions
|
@ -388,15 +388,21 @@
|
||||||
|
|
||||||
// Rename associated file
|
// Rename associated file
|
||||||
if (checkState.value) {
|
if (checkState.value) {
|
||||||
var renamed = item.renameAttachmentFile(newTitle.value);
|
var newFilename = newTitle.value.trim();
|
||||||
|
if (newFilename.search(/\.\w{1,10}$/) == -1) {
|
||||||
|
// User did not specify extension. Use current
|
||||||
|
var oldExt = item.getFilename().match(/\.\w{1,10}$/);
|
||||||
|
if (oldExt) newFilename += oldExt[0];
|
||||||
|
}
|
||||||
|
var renamed = item.renameAttachmentFile(newFilename);
|
||||||
if (renamed == -1) {
|
if (renamed == -1) {
|
||||||
var confirmed = nsIPS.confirm(
|
var confirmed = nsIPS.confirm(
|
||||||
window,
|
window,
|
||||||
'',
|
'',
|
||||||
newTitle.value + ' exists. Overwrite existing file?'
|
newFilename + ' exists. Overwrite existing file?'
|
||||||
);
|
);
|
||||||
if (confirmed) {
|
if (confirmed) {
|
||||||
item.renameAttachmentFile(newTitle.value, true);
|
item.renameAttachmentFile(newFilename, true);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
// If they said not to overwrite existing file,
|
// If they said not to overwrite existing file,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue