ahanikel commented on code in PR #1427:
URL: https://github.com/apache/jackrabbit-oak/pull/1427#discussion_r1599674013


##########
oak-segment-remote/src/main/java/org/apache/jackrabbit/oak/segment/remote/persistentcache/PersistentDiskCache.java:
##########
@@ -204,7 +204,17 @@ private void cleanUpInternal() {
                     }
                     if (cacheSize.get() > maxCacheSizeBytes * 0.66) {
                         File segment = segmentCacheEntry.getPath().toFile();
-                        cacheSize.addAndGet(-segment.length());
+                        long length = segment.length();
+                        if (length == 0) {
+                            if (logger.isDebugEnabled()) {
+                                logger.debug("Avoiding removal of zero-sized 
file {}", segmentCacheEntry.getPath());
+                            } else {
+                                logger.warn("Avoiding removal of zero-sized 
file.");
+                            }
+                            return;
+                        }
+                        long cacheSizeAfter = cacheSize.addAndGet(-length);
+                        diskCacheIOMonitor.updateCacheSize(cacheSizeAfter, 
directory.length());

Review Comment:
   You're both right, the directory size can only be calculated by traversing 
the directory, the size attribute only shows the size of the directory 
structure itself on disk. I'm going to change this to measure the calculated 
size and the size change instead.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscr...@jackrabbit.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to