diff options
| author | Chris Lu <chris.lu@gmail.com> | 2021-05-31 16:42:55 -0700 |
|---|---|---|
| committer | Chris Lu <chris.lu@gmail.com> | 2021-05-31 16:42:55 -0700 |
| commit | 556cc3a4ca6702346688a82e9b2fb72266c2c307 (patch) | |
| tree | 317fc9fa5ecd30a3234c1a65c6f9f33721f800d0 | |
| parent | 615cb24ba6b0045b8eb3ece8d78fb5ce6dfdea59 (diff) | |
| download | seaweedfs-556cc3a4ca6702346688a82e9b2fb72266c2c307.tar.xz seaweedfs-556cc3a4ca6702346688a82e9b2fb72266c2c307.zip | |
mount: avoid exception if disk cache is not initialized
related to https://github.com/chrislusf/seaweedfs/issues/2102
| -rw-r--r-- | weed/util/chunk_cache/on_disk_cache_layer.go | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/weed/util/chunk_cache/on_disk_cache_layer.go b/weed/util/chunk_cache/on_disk_cache_layer.go index a4b3b6994..b004913ef 100644 --- a/weed/util/chunk_cache/on_disk_cache_layer.go +++ b/weed/util/chunk_cache/on_disk_cache_layer.go @@ -42,6 +42,10 @@ func NewOnDiskCacheLayer(dir, namePrefix string, diskSize int64, segmentCount in func (c *OnDiskCacheLayer) setChunk(needleId types.NeedleId, data []byte) { + if len(c.diskCaches) == 0 { + return + } + if c.diskCaches[0].fileSize+int64(len(data)) > c.diskCaches[0].sizeLimit { t, resetErr := c.diskCaches[len(c.diskCaches)-1].Reset() if resetErr != nil { |
