Closed
Bug 793949
Opened 12 years ago
Closed 12 years ago
[OS.File] File.copy should not append data
Categories
(Toolkit Graveyard :: OS.File, defect)
Tracking
(Not tracked)
RESOLVED
FIXED
mozilla18
People
(Reporter: Yoric, Assigned: Yoric)
References
Details
Attachments
(2 files, 2 obsolete files)
1.03 KB,
patch
|
Yoric
:
review+
|
Details | Diff | Splinter Review |
1.65 KB,
patch
|
Yoric
:
review+
|
Details | Diff | Splinter Review |
Currently, the pump-based implementation of File.copy opens file with flags |write: true|. Consequently, copying on top of an existing file appends to this file. It should be |trunc: true|.
Assignee | ||
Comment 1•12 years ago
|
||
Assignee: nobody → dteller
Attachment #664347 -
Flags: review?(nfroyd)
Assignee | ||
Comment 2•12 years ago
|
||
Attachment #664350 -
Flags: review?(nfroyd)
![]() |
||
Comment 3•12 years ago
|
||
Comment on attachment 664347 [details] [diff] [review]
Companion testsuite
Review of attachment 664347 [details] [diff] [review]:
-----------------------------------------------------------------
::: toolkit/components/osfile/tests/mochi/worker_test_osfile_front.js
@@ +407,5 @@
> + // Copy a second time to ensure that we are overwriting the destination file,
> + // as expected
> + OS.File.copy(src_file_name, tmp_file_name);
> +
> + compare_files("test_copy_existing 2", src_file_name, tmp_file_name);
Please choose a different file to copy for this second test, just to ensure that the second copy is actually copying and not just no-op'ing or something.
Attachment #664347 -
Flags: review?(nfroyd) → review+
![]() |
||
Comment 4•12 years ago
|
||
Comment on attachment 664350 [details] [diff] [review]
Changing the flags in File.copy
Review of attachment 664350 [details] [diff] [review]:
-----------------------------------------------------------------
I'm assuming we don't have this problem on Windows because copy is implemented with an OS primitive rather than hand-rolling it ourselves?
::: toolkit/components/osfile/osfile_unix_front.jsm
@@ +517,5 @@
> source = File.open(sourcePath);
> if (options.noOverwrite) {
> dest = File.open(destPath, {create:true});
> } else {
> + dest = File.open(destPath, {trunc:true});
Doh.
Attachment #664350 -
Flags: review?(nfroyd) → review+
Assignee | ||
Comment 5•12 years ago
|
||
(In reply to Nathan Froyd (:froydnj) from comment #4)
> Comment on attachment 664350 [details] [diff] [review]
> Changing the flags in File.copy
>
> Review of attachment 664350 [details] [diff] [review]:
> -----------------------------------------------------------------
>
> I'm assuming we don't have this problem on Windows because copy is
> implemented with an OS primitive rather than hand-rolling it ourselves?
That's the idea.
>
> ::: toolkit/components/osfile/osfile_unix_front.jsm
> @@ +517,5 @@
> > source = File.open(sourcePath);
> > if (options.noOverwrite) {
> > dest = File.open(destPath, {create:true});
> > } else {
> > + dest = File.open(destPath, {trunc:true});
>
> Doh.
Yeah, I know :)
Assignee | ||
Comment 6•12 years ago
|
||
Attachment #664350 -
Attachment is obsolete: true
Attachment #664898 -
Flags: review+
Assignee | ||
Comment 7•12 years ago
|
||
Attachment #664347 -
Attachment is obsolete: true
Attachment #665187 -
Flags: review+
Assignee | ||
Updated•12 years ago
|
Keywords: checkin-needed
Assignee | ||
Comment 8•12 years ago
|
||
Comment 9•12 years ago
|
||
(In reply to David Rajchenbach Teller [:Yoric] from comment #8)
> Try: https://tbpl.mozilla.org/?tree=Try&rev=dc08d840e41c
Green on Try.
https://hg.mozilla.org/integration/mozilla-inbound/rev/dabd0af858d7
https://hg.mozilla.org/integration/mozilla-inbound/rev/4280a881fef0
Flags: in-testsuite+
Keywords: checkin-needed
Comment 10•12 years ago
|
||
https://hg.mozilla.org/mozilla-central/rev/dabd0af858d7
https://hg.mozilla.org/mozilla-central/rev/4280a881fef0
Status: NEW → RESOLVED
Closed: 12 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla18
Updated•2 years ago
|
Product: Toolkit → Toolkit Graveyard
You need to log in
before you can comment on or make changes to this bug.
Description
•