Bug 1372116 - P1: Create originInfo after creating metadata if the temporay storage has been initialized for persist(). r=janv

This commit is contained in:
Tom Tung 2017-06-27 04:41:38 -07:00
Родитель 2332473008
Коммит 03ec1c0d29
1 изменённых файлов: 21 добавлений и 6 удалений

Просмотреть файл

@ -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<nsIFile> 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);
&timestamp);
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;
}