diff --git a/server/src/main/java/com/usatiuk/dhfs/storage/files/service/DhfsFileServiceImpl.java b/server/src/main/java/com/usatiuk/dhfs/storage/files/service/DhfsFileServiceImpl.java index 6dbe80fa..cd0ac2b1 100644 --- a/server/src/main/java/com/usatiuk/dhfs/storage/files/service/DhfsFileServiceImpl.java +++ b/server/src/main/java/com/usatiuk/dhfs/storage/files/service/DhfsFileServiceImpl.java @@ -211,6 +211,10 @@ public class DhfsFileServiceImpl implements DhfsFileService { try { file.runReadLocked((fsNodeData, fileData) -> { var chunksAll = fileData.getChunks(); + if (chunksAll.isEmpty()) { + chunksList.set(new ArrayList<>()); + return null; + } chunksList.set(chunksAll.tailMap(chunksAll.floorKey(offset)).entrySet().stream().toList()); return null; }); @@ -219,6 +223,10 @@ public class DhfsFileServiceImpl implements DhfsFileService { return Optional.empty(); } + if (chunksList.get().isEmpty()) { + return Optional.of(new byte[0]); + } + var chunks = chunksList.get().iterator(); ByteBuffer buf = ByteBuffer.allocate(length);