From 1e5ef688044cf6b1457e034be92ecd45c710fffe Mon Sep 17 00:00:00 2001 From: Ben Kelly Date: Mon, 18 May 2015 12:11:32 -0700 Subject: [PATCH] Bug 1165119 Remove corrupt morgue directories polluting nightly profiles. r=janv --- dom/quota/QuotaManager.cpp | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/dom/quota/QuotaManager.cpp b/dom/quota/QuotaManager.cpp index 68601bf87d72..a49deb68f978 100644 --- a/dom/quota/QuotaManager.cpp +++ b/dom/quota/QuotaManager.cpp @@ -2015,6 +2015,35 @@ QuotaManager::InitializeRepository(PersistenceType aPersistenceType) return NS_OK; } +namespace { + +// The Cache API was creating top level morgue directories by accident for +// a short time in nightly. This unfortunately prevents all storage from +// working. So recover these profiles by removing these corrupt directories. +// This should be removed at some point in the future. +bool +MaybeRemoveCorruptDirectory(const nsAString& aLeafName, nsIFile* aDir) +{ +#ifdef NIGHTLY_BUILD + MOZ_ASSERT(aDir); + + if (aLeafName != NS_LITERAL_STRING("morgue")) { + return false; + } + + NS_WARNING("QuotaManager removing corrupt morgue directory."); + + nsresult rv = aDir->Remove(true /* recursive */); + NS_ENSURE_SUCCESS(rv, false); + + return true; +#else + return false +#endif // NIGHTLY_BUILD +} + +} // anonymous namespace + nsresult QuotaManager::InitializeOrigin(PersistenceType aPersistenceType, const nsACString& aGroup, @@ -2072,6 +2101,10 @@ QuotaManager::InitializeOrigin(PersistenceType aPersistenceType, return NS_ERROR_UNEXPECTED; } + if (MaybeRemoveCorruptDirectory(leafName, file)) { + continue; + } + Client::Type clientType; rv = Client::TypeFromText(leafName, clientType); if (NS_FAILED(rv)) { @@ -4173,6 +4206,10 @@ AsyncUsageRunnable::AddToUsage(QuotaManager* aQuotaManager, } } + if (MaybeRemoveCorruptDirectory(leafName, file)) { + continue; + } + Client::Type clientType; rv = Client::TypeFromText(leafName, clientType); if (NS_FAILED(rv)) {