diff --git a/dom/quota/ActorsParent.cpp b/dom/quota/ActorsParent.cpp index e87d3ffb74ba..90a36b5e8641 100644 --- a/dom/quota/ActorsParent.cpp +++ b/dom/quota/ActorsParent.cpp @@ -7649,7 +7649,8 @@ PersistOp::DoDirectoryWork(QuotaManager* aQuotaManager) AUTO_PROFILER_LABEL("PersistOp::DoDirectoryWork", OTHER); - // Update directory metadata on disk first. + // Update directory metadata on disk first. Then, create/update the originInfo + // if needed. nsCOMPtr directory; nsresult rv = aQuotaManager->GetDirectoryForOrigin(mPersistenceType.Value(), mOriginScope.GetOrigin(), @@ -7665,15 +7666,27 @@ PersistOp::DoDirectoryWork(QuotaManager* aQuotaManager) } if (created) { + int64_t timestamp; rv = CreateDirectoryMetadataFiles(directory, /* aPersisted */ true, mSuffix, mGroup, mOriginScope.GetOrigin(), - /* aTimestamp */ nullptr); + ×tamp); if (NS_WARN_IF(NS_FAILED(rv))) { return rv; } + + // Directory metadata has been successfully created. + // Create OriginInfo too if temporary storage was already initialized. + if (aQuotaManager->IsTemporaryStorageInitialized()) { + aQuotaManager->InitQuotaForOrigin(mPersistenceType.Value(), + mGroup, + mOriginScope.GetOrigin(), + /* aUsageBytes */ 0, + timestamp, + /* aPersisted */ true); + } } else { // Get the persisted flag (restore the metadata file if necessary). bool persisted; @@ -7718,11 +7731,13 @@ PersistOp::DoDirectoryWork(QuotaManager* aQuotaManager) return rv; } } - } - // Directory metadata has been successfully created/updated, try to update - // OriginInfo too (it's ok if OriginInfo doesn't exist yet). - aQuotaManager->PersistOrigin(mGroup, mOriginScope.GetOrigin()); + // Directory metadata has been successfully updated. + // Update OriginInfo too if temporary storage was already initialized. + if (aQuotaManager->IsTemporaryStorageInitialized()) { + aQuotaManager->PersistOrigin(mGroup, mOriginScope.GetOrigin()); + } + } return NS_OK; }