Closed Bug 68255 Opened 24 years ago Closed 24 years ago

download leaves behind a temp file

Categories

(SeaMonkey :: UI Design, defect)

All
OpenVMS
defect
Not set
normal

Tracking

(Not tracked)

VERIFIED FIXED
mozilla0.8.1

People

(Reporter: colin, Assigned: colin)

References

(Blocks 1 open bug)

Details

Attachments

(2 files)

If I download a file then while its downloading I can see that there are two versions of the temp file: NKH2N056.GZ;2 NKH2N056.GZ;1 After the download has completed the temp file is renamed to whatever name I chose for it, but version 1 of the file is left orphaned. We should really tidy up that file somehow. I believe the "problem" is here: http://lxr.mozilla.org/seamonkey/source/uriloader/exthandler/nsExternalHelperApp Service.cpp#758 The line of code is: rv = fileChannel->Init(mTempFile, -1, 0); The -1 is the ioFlags and later on -1 gets turned into PR_WRONLY | PR_CREATE_FILE | PR_TRUNCATE Since we have just created (and closed) the unique file, the PR_TRUNCATE is superfluous on this call. Trouble is that O_TRUNC on open() on OpenVMS means "create a new version of the file". I think I can fix the problem for OpenVMS and not break anyone else by changing the line to: rv = fileChannel->Init(mTempFile, PR_WRONLY | PR_CREATE_FILE, 0); I'll do some testing and see what gives.
This is mine.
Assignee: asa → colin
Status: NEW → ASSIGNED
Yep, that does fix the problem. Now I need to see how to get this checked in.
sspitzer and ducarroz know the file, and mscott seems to be the owner.
Component: Browser-General → XP Apps
QA Contact: doronr → sairuh
Looking for some reviews. Seth and mscott, could you folks r and sr respectively? Thanks, Colin.
looks good, but have you tested this patch any other platforms?
Unfortunately I don't have any other build platforms available. So the answer's no.
I'll try linux for you, mscott can you do win32?
rebuilding and testing now. after linux, I can try mac also. while I do that, you might want to scour the tree looking for other cases where we pass in -1.
linux seems to work fine. I'm able to download files and save them no problem. rebuild mac now. r=sspitzer, but mscott's review is the one that matters.
I found another couple of -1 instances in the tree, but I think these are OK. This one was really only a problem because we create the file, close it, and then open it (with O_TRUNC) before we write to it. Its that sequence which causes an extra version of the file to be created on OpenVMS.
mac seems fine too. on both platforms, I can download and save images.
mscott: looking for an a= if you please.
sr=mscott
Just realised that I never did attach the patch. I'll do that now. But it is just that one liner. Honest!
Attached patch Proposed patch (deleted) — Splinter Review
I need to re-do this patch and re-test since DougT's big necko changes altered the very line my patch is changing. I'm on vacation starting tomorrow and so won't be able to get to this until the beginning of March.
Thanks to Doug's rewrite the download file is only opened once now, and so this problem has gone away. Thanks Doug! Marking fixed.
Status: ASSIGNED → RESOLVED
Closed: 24 years ago
Resolution: --- → FIXED
Damn. I just downloaded a file and got two versions of the temp file. This is with a 2001030613 build. Maybe I only got one version when I tried it before because the file had finished downloading before I dismissed the "save as" box? Anyway, I'm re-opening and will debug again.
Status: RESOLVED → REOPENED
Resolution: FIXED → ---
Attached patch Patch for current necko code (deleted) — Splinter Review
The new patch (above) is basically the same as the previous one. The temp file is created and immediately closed by a call to nsLocalFile::CreateUnique which goes out of its way to create (and not just open) the file. Therefore when we later open the file to actually write to it, we do not need PR_TRUNCATE since we KNOW the file is empty. Looking for r=sspitzer and sr=mscott again.
Changing milestone to 0.81. I'd really like to get this fix in. My patch was approved before, I just need to get the revised patch (because the code changed from under me) approved and I'll check it in.
Target Milestone: --- → mozilla0.8.1
sr=mscott
Checked in. revision 1.55. Just made it in to M0.81.
Status: REOPENED → RESOLVED
Closed: 24 years ago24 years ago
Resolution: --- → FIXED
vrfy using 2001.05.29.0x comm bits on linux, winnt and mac...
Status: RESOLVED → VERIFIED
Blocks: 129923
Product: Core → Mozilla Application Suite
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: