mirror of
https://github.com/usatiuk/dhfs.git
synced 2025-10-28 12:37:48 +01:00
fix for reading empty files
This commit is contained in:
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user