mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-19 00:05:36 +00:00
Bug 1629825 - Delete Appcache directory when storage pref is turned off r=necko-reviewers,kershaw
This bug was initially about adding a test that we can still clear appcache data even when the storage pref is off. However, due to the fact that we only check the pref at startup and then are unable to access the storage device if disabled, it's best to just delete the OfflineCache folder shortly after startup. Differential Revision: https://phabricator.services.mozilla.com/D90395
This commit is contained in:
parent
6007e4f7d3
commit
277da76cef
17
netwerk/cache/nsCacheService.cpp
vendored
17
netwerk/cache/nsCacheService.cpp
vendored
@ -268,6 +268,23 @@ nsresult nsCacheProfilePrefObserver::ReadPrefs(nsIPrefBranch* branch) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
if (!mOfflineStorageCacheEnabled) {
|
||||
// Dispatch cleanup task
|
||||
nsCOMPtr<nsIRunnable> runnable =
|
||||
NS_NewRunnableFunction("Delete OfflineCache", []() {
|
||||
nsCOMPtr<nsIFile> dir;
|
||||
nsCacheService::GetAppCacheDirectory(getter_AddRefs(dir));
|
||||
bool exists = false;
|
||||
if (dir && NS_SUCCEEDED(dir->Exists(&exists)) && exists) {
|
||||
// Delay delete by 1 minute to avoid IO thrash on startup.
|
||||
CACHE_LOG_INFO(
|
||||
("Queuing Delete of AppCacheDirectory in 60 seconds"));
|
||||
nsDeleteDir::DeleteDir(dir, false, 60000);
|
||||
}
|
||||
});
|
||||
Unused << nsCacheService::DispatchToCacheIOThread(runnable);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user