Skip to content

Commit a2951d2

Browse files
authored
Merge pull request #1352 from asurdej-comcast/disk_cache
[DiskCache] Disable HTTP cache if not enough disk space avaialble
2 parents 2b4f979 + 19512f7 commit a2951d2

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

Source/WebKit/Shared/CacheModel.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#include "CacheModel.h"
2828

2929
#include <algorithm>
30+
#include <wtf/Assertions.h>
3031
#include <wtf/RAMSize.h>
3132
#include <wtf/Seconds.h>
3233
#include <wtf/StdLibExtras.h>
@@ -183,8 +184,12 @@ uint64_t calculateURLCacheDiskCapacity(CacheModel cacheModel, uint64_t diskFreeS
183184
if (units != 1)
184185
value = value.substring(0, value.length()-1);
185186

186-
size_t size = size_t(parseInteger<uint64_t>(s).value_or(1) * units);
187-
urlCacheDiskCapacity = (unsigned long)(size);
187+
urlCacheDiskCapacity = parseInteger<uint64_t>(value).value_or(0) * units;
188+
if (urlCacheDiskCapacity > diskFreeSize * MB) {
189+
WTFLogAlways("Disabling cache due to lack of disk space (wanted space: %ju, disk free space: %ju [bytes])",
190+
urlCacheDiskCapacity, diskFreeSize * MB);
191+
urlCacheDiskCapacity = 0;
192+
}
188193
}
189194

190195
return urlCacheDiskCapacity;

0 commit comments

Comments
 (0)