Save As to File seems to delete before write



16 years ago
11 years ago


(Reporter: kyle, Assigned: sspitzer)



Firefox Tracking Flags

(Not tracked)




16 years ago
User-Agent:       Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4) Gecko/20030703
Build Identifier: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4) Gecko/20030703

I'm trying to Save As an email message to a unix pipe (created with mkfifo). 
The purpose of this is I have a process on the other end of the pipe that will
read the message and log it to my SQL contact database.  All would be fine
except mozilla seems to delete the pipe before writing to it.  So my fifo gets
deleted and then mozilla ends up just creating a regular file instead of writing
to the pipe.

Is it possible to just open the file (if it exists) for write at 0 and truncate,
rather than deleting, and then writing?

Reproducible: Always

Steps to Reproduce:
1. mkfifo testfifo.eml
2. cat testfifo.eml
3. execute File-Save_As in mozilla
4. Select the file testfito.eml

Actual Results:  
testfifo gets deleted and a new file is created called testfifo.eml which
contains the contents of the message.

Expected Results:  
mozilla should (imho) simply write the contents of the message out to the file
without deleting it.  The contents of the message should appear as the output of
the cat process.

This integration effort is part of

Seems like this fix would be applicable to any special file or fifo in the
filesystem used for capturing file data in this way.

Maybe this really should be an enhancement request, but since I haven't been
able to figure out a workaround, I'll list it as normal for now.

Comment 1

16 years ago
OK, I found 2 things:

1. If the mail folder I'm saving from is in a pop account, this problem does not
occur (no pre-delete).
2. If the folder is an imap or news folder, the file does get deleted before write.

I've found in base/util/nsMsgMailNewsUrl.cpp, at the top of method
nsMsgSaveAsListener::SetupMsgWriteStream the comment:
// if the file already exists, delete it.

Is this really necessary?  Can we just delete these 3 lines?  If not, can we
just truncate the file to 0 somehow?

It looks like soon after in GetOutputStream, an OpenStreamForWriting() is
performed which should truncate the file, I would think...

Product: MailNews → Core
This is an automated message, with ID "auto-resolve01".

This bug has had no comments for a long time. Statistically, we have found that
bug reports that have not been confirmed by a second user after three months are
highly unlikely to be the source of a fix to the code.

While your input is very important to us, our resources are limited and so we
are asking for your help in focussing our efforts. If you can still reproduce
this problem in the latest version of the product (see below for how to obtain a
copy) or, for feature requests, if it's not present in the latest version and
you still believe we should implement it, please visit the URL of this bug
(given at the top of this mail) and add a comment to that effect, giving more
reproduction information if you have it.

If it is not a problem any longer, you need take no action. If this bug is not
changed in any way in the next two weeks, it will be automatically resolved.
Thank you for your help in this matter.

The latest beta releases can be obtained from:
This bug has been automatically resolved after a period of inactivity (see above
comment). If anyone thinks this is incorrect, they should feel free to reopen it.
Last Resolved: 13 years ago
Resolution: --- → EXPIRED
Product: Core → MailNews Core
You need to log in before you can comment on or make changes to this bug.