Closed
Bug 943422
Opened 11 years ago
Closed 11 years ago
Implement FileUtils.openAtomicFileOutputStream()
Categories
(Toolkit :: General, defect)
Toolkit
General
Tracking
()
RESOLVED
FIXED
mozilla29
People
(Reporter: Yoric, Assigned: lpy)
References
(Blocks 1 open bug)
Details
(Keywords: main-thread-io, Whiteboard: [Async][mentor=Yoric][lang=js])
Attachments
(1 file, 4 obsolete files)
9.90 KB,
patch
|
lpy
:
review+
|
Details | Diff | Splinter Review |
At the moment, FileUtils offers a method openSafeFileOutputStream() which opens a safe file output stream. Bug 928321 introduces a faster variant, the atomic file output stream. We should:
- create a method FileUtils.openAtomicFileOutputStream() that opens an atomic output stream;
- add comments in FileUtils.jsm explaining that openAtomicFileOutputStream() is generally better;
- update the documentation.
Assignee | ||
Comment 1•11 years ago
|
||
Hi David, I take this bug. Should I wait until Bug 928321 checkin?
Assignee | ||
Updated•11 years ago
|
Assignee: nobody → pylaurent1314
Reporter | ||
Comment 2•11 years ago
|
||
(In reply to Peiyong Lin[:lpy] from comment #1)
> Hi David, I take this bug. Should I wait until Bug 928321 checkin?
Yes, please.
Assignee | ||
Comment 3•11 years ago
|
||
Implement |FileUtils.openAtomicFileOutputStream()|
Attachment #8344194 -
Flags: review?(dteller)
Reporter | ||
Comment 4•11 years ago
|
||
Comment on attachment 8344194 [details] [diff] [review]
bug943422-v1.patch
Review of attachment 8344194 [details] [diff] [review]:
-----------------------------------------------------------------
Looks good.
I'm not setting r+ yet, because I'd like a test in toolkit/modules/tests/xpcshell/test_FileUtils.js
Attachment #8344194 -
Flags: review?(dteller)
Assignee | ||
Comment 5•11 years ago
|
||
Add openAtomicFileOutputStream in toolkit/modules/tests/xpcshell/test_FileUtils.js
By the way, I saw |closeSafeFileOutputStream| in here http://mxr.mozilla.org/mozilla-central/source/toolkit/modules/FileUtils.jsm#125, should I implement |closeAtomicFileOutputStream|?
Thanks!
Attachment #8344194 -
Attachment is obsolete: true
Attachment #8346504 -
Flags: review?(dteller)
Assignee | ||
Comment 6•11 years ago
|
||
Update again. :) Add |closeAtomicFileOutputStream|, tests in toolkit/modules/tests/xpcshell
Attachment #8346504 -
Attachment is obsolete: true
Attachment #8346504 -
Flags: review?(dteller)
Attachment #8346529 -
Flags: review?(dteller)
Reporter | ||
Comment 7•11 years ago
|
||
Comment on attachment 8346529 [details] [diff] [review]
bug943422-V3.patch
Review of attachment 8346529 [details] [diff] [review]:
-----------------------------------------------------------------
::: toolkit/modules/tests/xpcshell/test_FileUtils.js
@@ +128,5 @@
>
> run_next_test();
> });
>
> +add_test(function test_openAtomicFileOutputStream_defaultFlags() {
A bit too much copy&paste for my taste. Could you factor the code from openSafeFileOutputStream and openAtomicFileOutputStream tests, since they differ only from two function calls?
Attachment #8346529 -
Flags: review?(dteller) → feedback+
Assignee | ||
Comment 8•11 years ago
|
||
Thank you :)
I also do this for |test_openFileOutputStream*|.
Attachment #8346529 -
Attachment is obsolete: true
Attachment #8346622 -
Flags: review?(dteller)
Reporter | ||
Comment 9•11 years ago
|
||
Comment on attachment 8346622 [details] [diff] [review]
bug943422-V4.patch
Review of attachment 8346622 [details] [diff] [review]:
-----------------------------------------------------------------
Looks good to me, with a few minor changes.
Have you run this through Try yet?
::: toolkit/modules/tests/xpcshell/test_FileUtils.js
@@ +90,5 @@
>
> run_next_test();
> });
>
> +let openFileOutputStream_defaultFlags = function (aArg, aFileName) {
"aArg" is not a very useful name, "aKind" would be nicer.
@@ +97,5 @@
> + if (aArg == "atomic") {
> + fos = FileUtils.openAtomicFileOutputStream(file);
> + } else if (aArg == "safe") {
> + fos = FileUtils.openSafeFileOutputStream(file);
> + } else {
Just to be on the safe side, can you ensure that the string is always one of the accepted strings ("atomic", "safe", "")?
@@ +128,2 @@
>
> +let openFileOutputStream_modeFlags = function(aArg, aFileName) {
Same comments below.
Attachment #8346622 -
Flags: review?(dteller) → review+
Assignee | ||
Comment 10•11 years ago
|
||
use |do_check_true| to ensure aKind to be one of |("atomic", "safe", "")|
Attachment #8346622 -
Attachment is obsolete: true
Attachment #8348008 -
Flags: review+
Assignee | ||
Comment 11•11 years ago
|
||
I set the checkin flag, will update document after patch land. Thank you Yoric :)
Assignee | ||
Updated•11 years ago
|
Keywords: checkin-needed
Comment 12•11 years ago
|
||
Flags: in-testsuite+
Keywords: checkin-needed
Comment 13•11 years ago
|
||
Status: NEW → RESOLVED
Closed: 11 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla29
You need to log in
before you can comment on or make changes to this bug.
Description
•