Skip to content

Commit

Permalink
Fix #38
Browse files Browse the repository at this point in the history
  • Loading branch information
lilith committed Dec 10, 2020
1 parent 6b7a214 commit 51d8d20
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/Imazen.HybridCache/CleanupManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ await Database.CreateRecordIfSpace(shard, cacheEntry.RelativePath,
if (!allowEviction) return new ReserveSpaceResult(){ Success = false, Message = "Eviction disabled in sync mode"};

var entryDiskSpace = EstimateEntryBytesWithOverhead(byteCount) +
Database.EstimateRecordDiskSpace(cacheEntry.RelativePath.Length + contentType.Length);
Database.EstimateRecordDiskSpace(cacheEntry.RelativePath.Length + (contentType?.Length ?? 0));

var missingSpace = Math.Max(0, await Database.GetShardSize(shard) + entryDiskSpace - shardSizeLimit);
// Evict space
Expand Down
2 changes: 1 addition & 1 deletion src/Imazen.HybridCache/MetaStore/Shard.cs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public async Task<bool> CreateRecordIfSpace(string relativePath, string contentT
using (await createLock.LockAsync())
{
var loadedDict = await GetLoadedDict();
var extraLogBytes = GetLogBytesOverhead(relativePath.Length + contentType.Length);
var extraLogBytes = GetLogBytesOverhead(relativePath.Length + (contentType?.Length ?? 0));

var existingDiskUsage = await GetShardSize();
if (existingDiskUsage + recordDiskSpace + extraLogBytes > diskSpaceLimit)
Expand Down

0 comments on commit 51d8d20

Please sign in to comment.