Closed
Bug 910885
Opened 11 years ago
Closed 11 years ago
Improve FileUtils.getDir(…, …, true) performance
Categories
(Toolkit :: General, defect)
Toolkit
General
Tracking
()
RESOLVED
FIXED
mozilla26
People
(Reporter: marco, Assigned: marco)
References
Details
Attachments
(1 file, 2 obsolete files)
1.54 KB,
patch
|
marco
:
review+
|
Details | Diff | Splinter Review |
nsIFile already creates any path segments that don't exist, so we can avoid to call |exists| and |create| for every path segment. We can also avoid calling |exists| and put the |create| call in a try block. I know the function will go away eventually, but in the meantime this small fix is really simple.
Attachment #797471 -
Flags: review?(dteller)
Comment 1•11 years ago
|
||
Comment on attachment 797471 [details] [diff] [review] improve_getdir_true Review of attachment 797471 [details] [diff] [review]: ----------------------------------------------------------------- ::: toolkit/modules/FileUtils.jsm @@ +67,5 @@ > + > + if (shouldCreate) { > + try { > + dir.create(Ci.nsIFile.DIRECTORY_TYPE, this.PERMS_DIRECTORY); > + } catch (ex if ex.result == Cr.NS_ERROR_FILE_ALREADY_EXISTS) {} Nit: Could you add a (trivial) comment explaining the empty brackets?
Attachment #797471 -
Flags: review?(dteller) → review+
Assignee | ||
Comment 2•11 years ago
|
||
Carrying r+.
Assignee: nobody → mcastelluccio
Attachment #797471 -
Attachment is obsolete: true
Status: NEW → ASSIGNED
Attachment #797595 -
Flags: review+
Assignee | ||
Comment 3•11 years ago
|
||
Looks like ellipsis characters cause build problems. https://tbpl.mozilla.org/?tree=Try&rev=43a19f905b68 https://tbpl.mozilla.org/?tree=Try&rev=3edc89cf937e
Attachment #797595 -
Attachment is obsolete: true
Attachment #797970 -
Flags: review+
Assignee | ||
Updated•11 years ago
|
Keywords: checkin-needed
Comment 4•11 years ago
|
||
https://hg.mozilla.org/integration/mozilla-inbound/rev/6bd785bca4ff
Keywords: checkin-needed
Comment 5•11 years ago
|
||
https://hg.mozilla.org/mozilla-central/rev/6bd785bca4ff
Status: ASSIGNED → RESOLVED
Closed: 11 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla26
Comment 6•11 years ago
|
||
This optimization introduces some unexpected errors on Windows, for example on these FileUtils.getFile usages: http://mxr.mozilla.org/mozilla-central/search?string=DefRt&find=dom&findi=&filter=^[^\0]*%24&hitlimit=&tree=mozilla-central FileUtils.getFile("DefRt", ["settings.json"], false); "DefRt" is c:\program files\Firefox\defaults And by default program files can only be read by a regular windows user. So FileUtils.getFile calls FileUtils.getDir with shouldCreate=true, to it tries to create the "defaults" directory and throws with a file access denied exception: NS_ERROR_FILE_ACCESS_DENIED: Component returned failure code: 0x80520015 (NS_ERROR_FILE_ACCESS_DENIED) [nsIFile.create] Right now I'm only seing this exception when trying to run gaia in firefox on Windows. But I wouldn't be surprised other usecases fail with the same exception. I don't really know how to address that without getting back to the original code, may be that? } catch (ex if ex.result == Cr.NS_ERROR_FILE_ALREADY_EXISTS) { //... + } catch (ex if ex.result == Cr.NS_ERROR_FILE_ACCESS_DENIED) { + if (!dir.exists()) + throw ex; + }
You need to log in
before you can comment on or make changes to this bug.
Description
•