Skip to content

Commit 950911b

Browse files
Avoid round-up of small volume capacities
For use cases where the volume capacity override option cannot be used, if we round small capacities to the next 1GB, we might use inadequate values for proper origin and total storage quota control. This is more critical for smaller capacities. Note: It is arguable if we should be rounding up at all, because that will lead to the use of wrong quotas. Rounding down would seem more sensible to ensure we won't attempt to use more space than the one available. For now, adjust for the small volume sizes
1 parent 38067c9 commit 950911b

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

Source/WebKit/NetworkProcess/storage/NetworkStorageManager.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,10 @@ void NetworkStorageManager::spaceGrantedForOrigin(const WebCore::ClientOrigin& o
389389
if (m_volumeCapacityOverride)
390390
volumeCapacity = m_volumeCapacityOverride;
391391
else if (auto capacity = FileSystem::volumeCapacity(m_path))
392-
volumeCapacity = WTF::roundUpToMultipleOf(defaultVolumeCapacityUnit, *capacity);
392+
if (*capacity < defaultVolumeCapacityUnit)
393+
volumeCapacity = *capacity;
394+
else
395+
volumeCapacity = WTF::roundUpToMultipleOf(defaultVolumeCapacityUnit, *capacity);
393396
if (volumeCapacity)
394397
m_totalQuota = *m_totalQuotaRatio * *volumeCapacity;
395398
else
@@ -551,7 +554,10 @@ OriginQuotaManager::Parameters NetworkStorageManager::originQuotaManagerParamete
551554
if (m_volumeCapacityOverride)
552555
volumeCapacity = m_volumeCapacityOverride;
553556
else if (auto capacity = FileSystem::volumeCapacity(m_path))
554-
volumeCapacity = WTF::roundUpToMultipleOf(defaultVolumeCapacityUnit, *capacity);
557+
if (*capacity < defaultVolumeCapacityUnit)
558+
volumeCapacity = *capacity;
559+
else
560+
volumeCapacity = WTF::roundUpToMultipleOf(defaultVolumeCapacityUnit, *capacity);
555561
if (volumeCapacity) {
556562
quota = m_originQuotaRatio.value() * volumeCapacity.value();
557563
increaseQuotaFunction = { };

0 commit comments

Comments
 (0)