Closed Bug 461256 Opened 16 years ago Closed 16 years ago

saving message leaves dest file locked

Categories

(MailNews Core :: Backend, defect)

x86
Windows XP
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: Bienvenu, Assigned: Bienvenu)

Details

Attachments

(1 file)

For example,

1. select message, and pick save as .eml file.

When the save as is done, TB will likely still be holding an open file handle on the file. This means that a subsequent save as will fail (perhaps there's a bug open on that already).

I've tracked this down to the fact that nsMessenger::SaveAs creates an nsSaveMsgListener, which opens an output stream on the file.

saveListener = new nsSaveMsgListener(localFile, this, nsnull);

then, when saving a message as a .eml file, it calls

      rv = messageService->SaveMessageToDisk(PromiseFlatCString(aURI).get(), localFile, PR_FALSE,
        urlListener, nsnull,
        PR_TRUE, mMsgWindow);

which creates its own output stream, and correctly closes it. However, nsSaveMsgListener does not close its output stream in this case, because it really is only being created to serve as nsIUrlListener, not a saveMsgListener (one who consumes the data).

The fix might be to have separate constructors for nsSaveMsgListener, one that doesn't open an output stream, and one that does, or to open the output stream lazily, when needed.
Attached patch proposed fix Splinter Review
don't create the output stream until we know we're going to need it.

I've verified that save as html still works (it goes through this code). I saw a few issues for save as template, but I think they're unrelated to this patch.
Attachment #344397 - Flags: superreview?(neil)
Attachment #344397 - Flags: review?(bugzilla)
Attachment #344397 - Flags: superreview?(neil) → superreview+
Attachment #344397 - Flags: review?(bugzilla) → review+
Status: NEW → RESOLVED
Closed: 16 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: