Closed
Bug 761138
Opened 12 years ago
Closed 12 years ago
[OS.File] Create / remove empty directories
Categories
(Toolkit Graveyard :: OS.File, enhancement)
Toolkit Graveyard
OS.File
Tracking
(Not tracked)
RESOLVED
FIXED
mozilla17
People
(Reporter: Yoric, Assigned: Yoric)
References
Details
(Keywords: dev-doc-needed)
Attachments
(4 files, 18 obsolete files)
3.89 KB,
patch
|
Yoric
:
review+
|
Details | Diff | Splinter Review |
2.72 KB,
patch
|
Yoric
:
review+
|
Details | Diff | Splinter Review |
802 bytes,
patch
|
Yoric
:
review+
|
Details | Diff | Splinter Review |
6.01 KB,
patch
|
Yoric
:
review+
|
Details | Diff | Splinter Review |
No description provided.
Assignee | ||
Updated•12 years ago
|
Summary: Implement directory removal in OS.File → [OS.File] Implement directory removal
Assignee | ||
Comment 1•12 years ago
|
||
After some tweaking around, I have come to the conclusion that we do not want to build recursive directory removal into OS.File yet. The main reason for this is that, depending on some information that OS.File does not have, we can have several very distinct implementations:
- move the directory to the OS-specific trash;
- move the directory to the OS-specific temporary directory;
- walk through the directory recursively, removing files as they come;
- walk through the directory recursively but asynchronously, removing a maximal number of files at a time, with a delay before two chunks;
- one of the two above combinations, but first move the directory to a kill-directory, that also needs to be emptied on startup;
- ...
For the moment, I therefore intend to only provide the features of moving directories/removing empty directories/walking through hierarchies. We will see for more advanced features once I have a clearer idea of the situation.
Assignee | ||
Updated•12 years ago
|
Assignee | ||
Comment 2•12 years ago
|
||
Assignee: nobody → dteller
Assignee | ||
Comment 3•12 years ago
|
||
Assignee | ||
Comment 4•12 years ago
|
||
Assignee | ||
Comment 5•12 years ago
|
||
Assignee | ||
Updated•12 years ago
|
Attachment #641881 -
Attachment is patch: true
Assignee | ||
Comment 6•12 years ago
|
||
Assignee | ||
Comment 7•12 years ago
|
||
Assignee | ||
Comment 8•12 years ago
|
||
Assignee | ||
Updated•12 years ago
|
Attachment #641879 -
Attachment description: Constants → 7. Constants
Assignee | ||
Updated•12 years ago
|
Summary: [OS.File] Implement directory removal → [OS.File] Create / remove empty directories
Assignee | ||
Comment 9•12 years ago
|
||
Attachment #641881 -
Attachment is obsolete: true
Attachment #641883 -
Attachment is obsolete: true
Attachment #641884 -
Attachment is obsolete: true
Assignee | ||
Comment 10•12 years ago
|
||
Attachment #641880 -
Attachment is obsolete: true
Attachment #641882 -
Attachment is obsolete: true
Assignee | ||
Updated•12 years ago
|
Attachment #644317 -
Flags: review?(taras.mozilla)
Updated•12 years ago
|
Attachment #644317 -
Flags: review?(taras.mozilla) → review+
Assignee | ||
Comment 11•12 years ago
|
||
I have slightly changed my roadmap. Unless someone explicitly needs this, I will land this after bug 729057.
Assignee | ||
Updated•12 years ago
|
Keywords: dev-doc-needed
Assignee | ||
Updated•12 years ago
|
Assignee: dteller → nobody
Component: Networking: File → OS.File
Product: Core → Toolkit
Assignee | ||
Updated•12 years ago
|
Assignee: nobody → dteller
Assignee | ||
Comment 12•12 years ago
|
||
Attachment #644317 -
Attachment is obsolete: true
Attachment #652432 -
Flags: review?(nfroyd)
Assignee | ||
Comment 13•12 years ago
|
||
Attachment #644318 -
Attachment is obsolete: true
Attachment #652434 -
Flags: review?(nfroyd)
Assignee | ||
Comment 14•12 years ago
|
||
Attachment #641879 -
Attachment is obsolete: true
Attachment #652436 -
Flags: review?(nfroyd)
Assignee | ||
Comment 15•12 years ago
|
||
Attachment #641877 -
Attachment is obsolete: true
Attachment #652437 -
Flags: review?(nfroyd)
Comment 16•12 years ago
|
||
Comment on attachment 652432 [details] [diff] [review]
mkdir/rmdir for Windows
Review of attachment 652432 [details] [diff] [review]:
-----------------------------------------------------------------
::: toolkit/components/osfile/osfile_win_front.jsm
@@ +328,5 @@
> + * directory does not exist yet.
> + */
> + File.removeEmptyDir = function removeEmptyDir(path, options) {
> + options = options || noOptions;
> + let result = UnixFile.rmdir(path);
Copy-paste-o?
@@ +346,5 @@
> + * @param {*=} options Additional options. This
> + * implementation interprets the following fields:
> + *
> + * - {number} winSecurity If specified, security attributes
> + * as per winapi function |CreateDirectory|. If unspecified,
Wait, what? The function takes a void* for security parameters and we merrily document that it takes numbers? That seems mistaken. The documentation should also be referring to |CreateDirectoryW|, no?
Attachment #652432 -
Flags: review?(nfroyd) → feedback+
Updated•12 years ago
|
Attachment #652436 -
Flags: review?(nfroyd) → review+
Updated•12 years ago
|
Attachment #652434 -
Flags: review?(nfroyd) → review+
Assignee | ||
Comment 17•12 years ago
|
||
(In reply to Nathan Froyd (:froydnj) from comment #16)
> Comment on attachment 652432 [details] [diff] [review]
> mkdir/rmdir for Windows
>
> Review of attachment 652432 [details] [diff] [review]:
> -----------------------------------------------------------------
>
> ::: toolkit/components/osfile/osfile_win_front.jsm
> @@ +328,5 @@
> > + * directory does not exist yet.
> > + */
> > + File.removeEmptyDir = function removeEmptyDir(path, options) {
> > + options = options || noOptions;
> > + let result = UnixFile.rmdir(path);
>
> Copy-paste-o?
Well-spotted, thanks.
>
> @@ +346,5 @@
> > + * @param {*=} options Additional options. This
> > + * implementation interprets the following fields:
> > + *
> > + * - {number} winSecurity If specified, security attributes
> > + * as per winapi function |CreateDirectory|. If unspecified,
>
> Wait, what? The function takes a void* for security parameters and we
> merrily document that it takes numbers? That seems mistaken.
Documentation error, indeed.
> The
> documentation should also be referring to |CreateDirectoryW|, no?
Well, officially, according to Microsoft, the function is called |CreateDirectory|. The fact that it is #defined to |CreateDirectoryW| is an implementation trick that I do not want to document.
Assignee | ||
Comment 18•12 years ago
|
||
Attachment #652432 -
Attachment is obsolete: true
Attachment #652463 -
Flags: review?(nfroyd)
Comment 19•12 years ago
|
||
(In reply to David Rajchenbach Teller from comment #17)
> > @@ +346,5 @@
> > > + * @param {*=} options Additional options. This
> > > + * implementation interprets the following fields:
> > > + *
> > > + * - {number} winSecurity If specified, security attributes
> > > + * as per winapi function |CreateDirectory|. If unspecified,
> >
> > Wait, what? The function takes a void* for security parameters and we
> > merrily document that it takes numbers? That seems mistaken.
>
> Documentation error, indeed.
Neither here nor there, but do we really have a standardized way of getting alternative security attributes to pass to the function? If the answer is "no" or "do it via ctypes", that's ok.
> > The
> > documentation should also be referring to |CreateDirectoryW|, no?
>
> Well, officially, according to Microsoft, the function is called
> |CreateDirectory|. The fact that it is #defined to |CreateDirectoryW| is an
> implementation trick that I do not want to document.
A pox on Microsoft's liberal use of #define'ing functions and whatnot in their headers. Carry on.
Updated•12 years ago
|
Attachment #652463 -
Flags: review?(nfroyd) → review+
Assignee | ||
Comment 20•12 years ago
|
||
(In reply to Nathan Froyd (:froydnj) from comment #19)
> (In reply to David Rajchenbach Teller from comment #17)
> > > @@ +346,5 @@
> > > > + * @param {*=} options Additional options. This
> > > > + * implementation interprets the following fields:
> > > > + *
> > > > + * - {number} winSecurity If specified, security attributes
> > > > + * as per winapi function |CreateDirectory|. If unspecified,
> > >
> > > Wait, what? The function takes a void* for security parameters and we
> > > merrily document that it takes numbers? That seems mistaken.
> >
> > Documentation error, indeed.
>
> Neither here nor there, but do we really have a standardized way of getting
> alternative security attributes to pass to the function? If the answer is
> "no" or "do it via ctypes", that's ok.
For the moment, "do it via ctypes". Adding this at a later stage should be possible, if it becomes necessary.
>
> > > The
> > > documentation should also be referring to |CreateDirectoryW|, no?
> >
> > Well, officially, according to Microsoft, the function is called
> > |CreateDirectory|. The fact that it is #defined to |CreateDirectoryW| is an
> > implementation trick that I do not want to document.
>
> A pox on Microsoft's liberal use of #define'ing functions and whatnot in
> their headers. Carry on.
Yeah, multiple poxes on winAPI for just about everything. And don't get me started on paths :)
Comment 21•12 years ago
|
||
Comment on attachment 652437 [details] [diff] [review]
Companion testsuite
Review of attachment 652437 [details] [diff] [review]:
-----------------------------------------------------------------
::: toolkit/components/osfile/tests/mochi/worker_test_osfile_front.js
@@ +622,5 @@
> +{
> + ok(true, "test_mkdir: Starting");
> +
> + let dirName = "test_dir.tmp";
> + OS.File.removeEmptyDir(dirName, {ignoreAbsent: true});
Checking that you throw for not-present ignoreAbsent in this case would be a good idea.
@@ +626,5 @@
> + OS.File.removeEmptyDir(dirName, {ignoreAbsent: true});
> +
> + ok(true, "test_mkdir: Creating directory");
> + OS.File.makeDir(dirName);
> + ok(true, OS.File.stat(dirName).isDir, "test_mkdir: Created directory is a directory");
What do you think about checking makeDir(dir) when dir already exists and/or is a file?
@@ +634,5 @@
> + try {
> + OS.File.stat(dirName);
> + ok(false, "test_mkdir: Directory was not removed");
> + } catch (x) {
> + ok(x instanceof OS.File.Error && x.becauseNoSuchFile, "test_mkdir: Directory was correcly removed");
Just "test_mkdir: Directory was removed"; shorter and fixes the typo. :)
@@ +636,5 @@
> + ok(false, "test_mkdir: Directory was not removed");
> + } catch (x) {
> + ok(x instanceof OS.File.Error && x.becauseNoSuchFile, "test_mkdir: Directory was correcly removed");
> + }
> +
Checking that you throw for removing a non-empty directory would be good. Checking that you throw for rmdir'ing a file would be good as well.
Attachment #652437 -
Flags: review?(nfroyd) → feedback+
Assignee | ||
Comment 22•12 years ago
|
||
Here we go
Attachment #652437 -
Attachment is obsolete: true
Attachment #652732 -
Flags: review?(nfroyd)
Comment 23•12 years ago
|
||
Comment on attachment 652732 [details] [diff] [review]
Companion testsuite, v2
Review of attachment 652732 [details] [diff] [review]:
-----------------------------------------------------------------
r=me with the changes below.
::: toolkit/components/osfile/tests/mochi/worker_test_osfile_front.js
@@ +627,5 @@
> +
> + // Check that removing absent directories is handled correctly
> + let exn;
> + try {
> + OS.File.removeEmptyDir(dirName, {ignoreAbsent: true});
This looks like it's duplicating the test 5 lines earlier. Why not just use the earlier one for the test or delete the earlier one?
Attachment #652732 -
Flags: review?(nfroyd) → review+
Assignee | ||
Comment 24•12 years ago
|
||
Attachment #652434 -
Attachment is obsolete: true
Attachment #653770 -
Flags: review+
Assignee | ||
Comment 25•12 years ago
|
||
Attachment #652463 -
Attachment is obsolete: true
Attachment #653771 -
Flags: review+
Assignee | ||
Comment 26•12 years ago
|
||
Attachment #653771 -
Attachment is obsolete: true
Attachment #653777 -
Flags: review+
Assignee | ||
Comment 27•12 years ago
|
||
Attachment #652436 -
Attachment is obsolete: true
Attachment #653779 -
Flags: review+
Assignee | ||
Comment 28•12 years ago
|
||
Attachment #652732 -
Attachment is obsolete: true
Attachment #653780 -
Flags: review+
Assignee | ||
Updated•12 years ago
|
Keywords: checkin-needed
Comment 29•12 years ago
|
||
Looks like this is failing tests on Windows.
https://tbpl.mozilla.org/?tree=Try&rev=e0fee2e553ca
https://tbpl.mozilla.org/php/getParsedLog.php?id=14590527&tree=Try
13620 INFO TEST-PASS | chrome://mochitests/content/chrome/toolkit/components/osfile/tests/mochi/test_osfile_front.xul | test_mkdir: Creating directory that already exists
13621 ERROR TEST-UNEXPECTED-FAIL | chrome://mochitests/content/chrome/toolkit/components/osfile/tests/mochi/test_osfile_front.xul | test_mkdir: makeDir over an existing directory failed for all the right reasons
13622 INFO TEST-PASS | chrome://mochitests/content/chrome/toolkit/components/osfile/tests/mochi/test_osfile_front.xul | test_mkdir: Directory was removed
Keywords: checkin-needed
Assignee | ||
Comment 30•12 years ago
|
||
Investigating
Assignee | ||
Comment 31•12 years ago
|
||
Attachment #653779 -
Attachment is obsolete: true
Attachment #654539 -
Flags: review+
Assignee | ||
Comment 32•12 years ago
|
||
Attachment #653777 -
Attachment is obsolete: true
Attachment #654540 -
Flags: review+
Assignee | ||
Updated•12 years ago
|
Keywords: checkin-needed
Comment 33•12 years ago
|
||
Green on Try. Sorry for the obscenely long delay.
https://tbpl.mozilla.org/?tree=Try&rev=c464f2934ab8
https://hg.mozilla.org/integration/mozilla-inbound/rev/f9b8fb3c9395
https://hg.mozilla.org/integration/mozilla-inbound/rev/d94e6c20c4dc
https://hg.mozilla.org/integration/mozilla-inbound/rev/3eb65ac5a609
https://hg.mozilla.org/integration/mozilla-inbound/rev/1fd86c175258
Comment 34•12 years ago
|
||
https://hg.mozilla.org/mozilla-central/rev/f9b8fb3c9395
https://hg.mozilla.org/mozilla-central/rev/d94e6c20c4dc
https://hg.mozilla.org/mozilla-central/rev/3eb65ac5a609
https://hg.mozilla.org/mozilla-central/rev/1fd86c175258
Status: NEW → RESOLVED
Closed: 12 years ago
Resolution: --- → FIXED
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
•