Closed Bug 752407 Opened 12 years ago Closed 12 years ago

Thumbnail cache should be created in the Local profile folder, not the Roaming ones

Categories

(Firefox :: General, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
Firefox 16
Tracking Status
firefox15 + unaffected

People

(Reporter: danialhorton, Assigned: ttaubert)

References

Details

Attachments

(1 file, 3 obsolete files)

User Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:15.0) Gecko/15.0 Firefox/15.0a1
Build ID: 20120506030520

Steps to reproduce:

Opened a recent nightly with the new thumbnail api/store folder


Actual results:

\Thumbnails\ was created in AppData\Roaming\Mozilla\Firefox\Profiles\4-Nightly\ AppData\Local\Mozilla\Firefox\Profiles\4-Nightly\


Expected results:

As a destroyable cache, this should have been placed in AppData\Local\Mozilla\Firefox\Profiles\4-Nightly\

The current location poses an annoyance to backup tools, as it will be now including alot of uncompressible megabytes  by default in the backup archive.
err, woops, that actual results should have only listed the Roaming target >.<
I think makes sense considered it's volatile data that can be rebuilt (sort of a cache), though I'm not sure whether it was done on purpose considering that valuable data one may not be willing to lose when migrating (in such a case this may end up being a wontfix)
Status: UNCONFIRMED → NEW
Component: Untriaged → General
Ever confirmed: true
QA Contact: untriaged → general
Summary: Thumbnail cache is created in Roaming\Mozilla\...... instead of Local\Mozilla\..... → Thumbnail cache should be created in the Local profile folder, not the Roaming ones
Blocks: 744388
Backup tools can easily be adapted to transfer local data,

but this has the potential of being a security concern.

Consider the scenario where a user is working on some corporate images and documents in his private office, but the User profiles are stored elsewhere.

In this case, instead of the images being stored on his pc in appdata\Local, they are written back to his user profile on the server
(In reply to Marco Bonardo [:mak] from comment #2)
> I think makes sense considered it's volatile data that can be rebuilt (sort
> of a cache), though I'm not sure whether it was done on purpose considering
> that valuable data one may not be willing to lose when migrating (in such a
> case this may end up being a wontfix)

Thumbnails are considered somewhat volatile and get rebuilt.

So we're currently using "ProfD/thumbnails" as the directory. Should we instead use "LocalAppData/thumbnails"? Is this a Win-only fix then?
(In reply to Gian-Carlo Pascutto (:gcp) from comment #5)
> Here's how to get the Local Profile dir:
> https://mxr.mozilla.org/mozilla2.0/source/toolkit/components/url-classifier/
> src/nsUrlClassifierDBService.cpp#1370

Thanks!
Assignee: nobody → ttaubert
Status: NEW → ASSIGNED
Hardware: x86_64 → All
Version: 15 Branch → Trunk
Correction, forgot a ProfD occurence.
Attachment #627136 - Attachment is obsolete: true
Attachment #627136 - Flags: review?(mak77)
Attachment #627138 - Flags: review?(mak77)
I just found bug 606575 that looks interesting and likely to be fixed first, cause on first profile creation we'd still put thumbs in the wrong place.

Actually, this patch changes the default folder, though I wonder if we should provide some migration path, so that the old roaming folder gets deleted, some users already have it taking a bunch of space (even 1GB from what I heard) and after this patch will just be a zombie folder and we'll take double the space.  It's true this only went to Nightly testers, though many may not be aware of this change and the need to remove the roaming folder.
Depends on: 606575
do we have some kind of "versioning" of the thumbnails service storage?
(In reply to Marco Bonardo [:mak] from comment #9)
> I just found bug 606575 that looks interesting and likely to be fixed first,
> cause on first profile creation we'd still put thumbs in the wrong place.

Good catch, thanks.

> Actually, this patch changes the default folder, though I wonder if we
> should provide some migration path, so that the old roaming folder gets
> deleted, some users already have it taking a bunch of space (even 1GB from
> what I heard) and after this patch will just be a zombie folder and we'll
> take double the space.  It's true this only went to Nightly testers, though
> many may not be aware of this change and the need to remove the roaming
> folder.

Yes, we should do this.

(In reply to Marco Bonardo [:mak] from comment #10)
> do we have some kind of "versioning" of the thumbnails service storage?

Not yet, as per our conversation on IRC we should add a simple preference that holds the current version number of the thumbnail storage.
Comment on attachment 627138 [details] [diff] [review]
use the local profile folder to store thumbnails, not the roaming one

Need to address comment #9.
Attachment #627138 - Flags: review?(mak77)
(In reply to Tim Taubert [:ttaubert] from comment #12)
> Comment on attachment 627138 [details] [diff] [review]
> use the local profile folder to store thumbnails, not the roaming one
> 
> Need to address comment #9.

Does it mean we should migrate/move the thumbnails dir from the roaming folder to the local profile one if it exists or simply remove the thumbnails dir in the roaming folder?
(In reply to Raymond Lee [:raymondlee] from comment #13)
> Does it mean we should migrate/move the thumbnails dir from the roaming
> folder to the local profile one if it exists or simply remove the thumbnails
> dir in the roaming folder?

As this is for Nightly testers only I'd say we should just remove the thumbnails folder in the roaming profile. We should not try to copy it as the roaming profile might be located on some network drive and this could take quite a long time. It's basically just to clean up things.
Marking tracking-firefox15 since deploying Firefox 15 at an enterprise with networked profiles could quickly fill the server's hard drive with thumbnails.
OS: Windows 7 → All
If the thumbnail cache is limited to a real tiny cache (depending on how the expiration will be done in bug 754671, for example when only the top-9 are stored), it might not matter anymore if it's stored in Local or Roaming. Storing it in Local can also be considered a disadvantage if you log in on a different computer, and there's no cache anymore. Just saying ...
I agree that the reasoning in comment 15 for making this bug tracking doesn't make much sense. The problem is bug 754671 not getting fixed and/or bug 744388 not being backed out.

If those get fixed, this bug is mostly a non-issue. If those don't get fixed, this bug will do little to prevent the problem, you'll just have huge (multi-gigabyte) and useless Local profile dirs instead.
(In reply to Gian-Carlo Pascutto (:gcp) from comment #17)
> I agree that the reasoning in comment 15 for making this bug tracking
> doesn't make much sense. The problem is bug 754671 not getting fixed and/or
> bug 744388 not being backed out.

I'm not sure how you think the reasoning doesn't make sense.  We can't assume that bug 754671 will get fixed in 15 and depending on the fix it may not solve the problem of large roaming thumbnails folders. For example, a cap of 100MB still adds up (in terms of storage and bandwidth) when there are many users on a server.
>For example, a cap of 100MB still adds up (in terms of storage and bandwidth) when 
>there are many users on a server.

Maybe I'm misunderstanding how much data the feature needs to store to work. From the description it didn't sound like something that needs that amount of space *when working correctly*.

>We can't assume that bug 754671 will get fixed in 15

That's right. With it Firefox has unbounded fast profile growth for all users. It doesn't matter if its in Local or Roaming - both are very bad. 

You're making the band-aid a tracking bug for 15, implying that we'd consider shipping 15 with the bug. I don't think that is the right thing to do.
We'll track both bugs; IMO we should fix them both.
Regardless what we do with the size cap, I don't think we should use the roaming folder for volatile and non-dataloss-prone stuff, the roaming profile should stay as slim as possible, any cached data should go to the local profile.
Also, this has never been intended to band-aid the size issue, just to put things to their correct place.
Attachment #627138 - Attachment is obsolete: true
Attachment #630903 - Flags: review?(mak77)
Comment on attachment 630903 [details] [diff] [review]
use the local profile folder to store thumbnails, not the roaming one

Review of attachment 630903 [details] [diff] [review]:
-----------------------------------------------------------------

::: browser/components/thumbnails/PageThumbs.jsm
@@ +328,5 @@
> +  },
> +
> +  migrate: function Migrator_migrate() {
> +    while (this.currentVersion < LATEST_STORAGE_VERSION)
> +      this.migrateToNextVersion();

please always brace loops

@@ +335,5 @@
> +  migrateToNextVersion: function Migrator_migrateToNextVersion() {
> +    let version = this.currentVersion;
> +
> +    if (version == 0)
> +      this.removeThumbnailsFromRoamingProfile();

I think you may want to manage downgrades... so if a user goes back to a version using roaming profile, you should migrate him again once he upgrades again.

You may always set the version to latest, even on downgrade (that means reducing it), on upgrade the migration goes again through the steps, that should be built taking into account the fact they may be applied to a profile already migrated (this checking exists and such things).

Btw, in this case likely doesn't matter much cause this never made a release, so you may handle that in a followup or when needed.

@@ +339,5 @@
> +      this.removeThumbnailsFromRoamingProfile();
> +  },
> +
> +  removeThumbnailsFromRoamingProfile:
> +    function Migrator_removeThumbnailsFromRoamingProfile() {

don't indent this, just keep it at same level as the label and avoid the next newline

@@ +353,5 @@
> +      }
> +    }
> +
> +    // Bump the version number.
> +    this.currentVersion = 1;

I think from a code point of view would be better to do this inside migrateToNextVersion, the migrator helper itself should not take care of bumping the version, it's not its task, and is somehow hiding the fact.
What we do usually is something like

if (version < 1)
  doSomething
if (version < 2)
  doSomethingElse
...
setVersion(LATEST)

that basically would merge migrate and migrateToNextVersion to one method.
Though you may also just do, in migrateToNextVersion:

if (version < 1) {
  doSomething
  bump
} else if (version < 2) {
  doSomethingElse
  bump
}
Attachment #630903 - Flags: review?(mak77) → review+
(In reply to Marco Bonardo [:mak] from comment #24)
> I think you may want to manage downgrades... so if a user goes back to a
> version using roaming profile, you should migrate him again once he upgrades
> again.

Yes, good point. Setting version now always to the latest. The first migration can handle an already migrated profile and we'll take it into account for further migrations.

> I think from a code point of view would be better to do this inside
> migrateToNextVersion, the migrator helper itself should not take care of
> bumping the version, it's not its task, and is somehow hiding the fact.
> What we do usually is something like
> 
> if (version < 1)
>   doSomething
> if (version < 2)
>   doSomethingElse
> ...
> setVersion(LATEST)
> 
> that basically would merge migrate and migrateToNextVersion to one method.

I implemented exactly this. It's nicer and easier to read.
Attachment #630903 - Attachment is obsolete: true
Blocks: 754671
https://hg.mozilla.org/integration/fx-team/rev/960b6d4ea73b
Whiteboard: [fixed-in-fx-team]
Target Milestone: --- → Firefox 16
https://hg.mozilla.org/mozilla-central/rev/960b6d4ea73b
Status: ASSIGNED → RESOLVED
Closed: 12 years ago
Resolution: --- → FIXED
Whiteboard: [fixed-in-fx-team]
Marking Fx 15 as unaffected because bug 744388 has been backed out on Aurora.
Depends on: 767411
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: