Closed
Bug 553492
Opened 15 years ago
Closed 14 years ago
Add Addon.size to expose the addon's size on disk
Categories
(Toolkit :: Add-ons Manager, defect)
Toolkit
Add-ons Manager
Tracking
()
VERIFIED
FIXED
mozilla2.0b2
Tracking | Status | |
---|---|---|
blocking2.0 | --- | beta2+ |
People
(Reporter: Unfocused, Assigned: mossop)
References
Details
(Keywords: APIchange, Whiteboard: [rewrite][schemachange])
Attachments
(1 file)
(deleted),
patch
|
robert.strong.bugs
:
review+
|
Details | Diff | Splinter Review |
Add Addon.size to expose the addon's size on disk. This should be in bytes, or -1 for unknown.
Comment 1•14 years ago
|
||
Note that bug 550048 now displays the 'size' and even can sort on it, but the actual value seems to be a random value (because 'Addon.size' is not available).
So, this has become a more visible issue.
Assignee | ||
Comment 2•14 years ago
|
||
Ben, the place to start looking to add this value to the backend API is here: http://mxr.mozilla.org/mozilla-central/source/toolkit/mozapps/extensions/XPIProvider.jsm#4657
This is the wrapper that code outside the API sees and uses so you just need to add a size getter to it. In there aAddon._sourceBundle will be either an xpi file, in which case the size is obviously just the size of the file or a directory in which case you'll need to recurse through it adding up the full size. Because this might take time it is going to be sensible to cache the size the first time you calculate it and just return that directly for subsequent calls.
Assignee: nobody → bparr
Comment 3•14 years ago
|
||
Or calculate it after installation/update of an addon, and store that somewhere.
Assignee | ||
Updated•14 years ago
|
Assignee: bparr → dtownsend
blocking2.0: --- → beta2+
Whiteboard: [rewrite] → [rewrite][schemachange]
Assignee | ||
Comment 4•14 years ago
|
||
Bug 558834 is going to do a DB schema update to add this property.
Depends on: 558834
Assignee | ||
Updated•14 years ago
|
Whiteboard: [rewrite][schemachange] → [rewrite][schemachange][apichange]
Assignee | ||
Comment 5•14 years ago
|
||
This exposes the size property on add-on objects and adds implementations for plugins too. Also added support to the AddonRepository API to expose the size of the download in the same manner.
Attachment #454622 -
Flags: review?(robert.bugzilla)
Updated•14 years ago
|
Keywords: APIchange
Whiteboard: [rewrite][schemachange][apichange] → [rewrite][schemachange]
Version: unspecified → Trunk
Comment 6•14 years ago
|
||
Comment on attachment 454622 [details] [diff] [review]
patch rev 1
>diff --git a/toolkit/mozapps/extensions/AddonRepository.jsm b/toolkit/mozapps/extensions/AddonRepository.jsm
>--- a/toolkit/mozapps/extensions/AddonRepository.jsm
>+++ b/toolkit/mozapps/extensions/AddonRepository.jsm
>@@ -139,16 +139,22 @@ AddonSearchResult.prototype = {
> appDisabled: false,
>
> /**
> * True if the user wants this add-on to be disabled
> */
> userDisabled: false,
>
> /**
>+ * The size of the add-ons files in bytes. For add-ons that have not yet been
>+ * downloaded this may be an estimated value.
nit: s/add-ons files/add-on's files/ and s/For add-ons that have not/For an add-on that has not/
>+ */
>+ size: null,
>+
>+ /**
> * Indicates what scope the add-on is installed in, per profile, user,
> * system or application
> */
> scope: AddonManager.SCOPE_PROFILE,
>
> /**
> * True if the add-on is currently functional
> */
>diff --git a/toolkit/mozapps/extensions/PluginProvider.jsm b/toolkit/mozapps/extensions/PluginProvider.jsm
>--- a/toolkit/mozapps/extensions/PluginProvider.jsm
>+++ b/toolkit/mozapps/extensions/PluginProvider.jsm
>@@ -200,16 +200,42 @@ function PluginWrapper(aId, aName, aDesc
> });
>
> this.__defineGetter__("blocklistState", function() {
> let bs = Cc["@mozilla.org/extensions/blocklist;1"].
> getService(Ci.nsIBlocklistService);
> return bs.getPluginBlocklistState(aTags[0]);
> });
>
>+ this.__defineGetter__("size", function() {
>+ function getFileSize(aFile) {
>+ if (aFile.isSymlink())
>+ return 0;
>+
>+ if (!aFile.isDirectory())
>+ return aFile.fileSize;
>+
>+ let size = 0;
>+ let entries = aFile.directoryEntries.QueryInterface(Ci.nsIDirectoryEnumerator);
>+ let entry;
>+ while (entry = entries.nextFile)
>+ size += getFileSize(entry);
>+ entries.close();
>+ return size;
>+ }
>+
>+ let size = 0;
>+ let file = Cc["@mozilla.org/file/local;1"].createInstance(Ci.nsILocalFile);
>+ aTags.forEach(function(aTag) {
>+ file.initWithPath(aTag.fullpath);
>+ size += getFileSize(file);
>+ });
>+ return size;
>+ });
Seems like you could fairly easily check if the original file path is a symlink for the Linux case and get the size of the file while protecting against a symlink on Mac OS X pointing back to the original package.
I expected to see changes to XPIProvider.jsm in this patch... what's up with that?
Updated•14 years ago
|
Attachment #454622 -
Flags: review?(robert.bugzilla) → review+
Assignee | ||
Comment 7•14 years ago
|
||
Status: NEW → RESOLVED
Closed: 14 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla1.9.3b2
Comment 8•14 years ago
|
||
Verified fixed by landing and green tests.
Dave in which of the schemachange patches you track the bump of the schema version and the database upgrade?
Status: RESOLVED → VERIFIED
Flags: in-testsuite+
Flags: in-litmus-
Comment 9•14 years ago
|
||
(In reply to comment #8)
> Dave in which of the schemachange patches you track the bump of the schema
> version and the database upgrade?
Ok, that's bug 455264.
Comment 10•14 years ago
|
||
(In reply to comment #9)
> Ok, that's bug 455264.
Sorry, that was the attachment id of the patch. It's bug 558834 for real.
Comment 11•14 years ago
|
||
Note, the size of the default theme is not correct: 12.3KB?
Created bug 579831 for this.
You need to log in
before you can comment on or make changes to this bug.
Description
•