mirror of
https://github.com/usatiuk/dhfs.git
synced 2025-10-29 04:57:48 +01:00
fix for reading empty files
This commit is contained in:
@@ -211,6 +211,10 @@ public class DhfsFileServiceImpl implements DhfsFileService {
|
|||||||
try {
|
try {
|
||||||
file.runReadLocked((fsNodeData, fileData) -> {
|
file.runReadLocked((fsNodeData, fileData) -> {
|
||||||
var chunksAll = fileData.getChunks();
|
var chunksAll = fileData.getChunks();
|
||||||
|
if (chunksAll.isEmpty()) {
|
||||||
|
chunksList.set(new ArrayList<>());
|
||||||
|
return null;
|
||||||
|
}
|
||||||
chunksList.set(chunksAll.tailMap(chunksAll.floorKey(offset)).entrySet().stream().toList());
|
chunksList.set(chunksAll.tailMap(chunksAll.floorKey(offset)).entrySet().stream().toList());
|
||||||
return null;
|
return null;
|
||||||
});
|
});
|
||||||
@@ -219,6 +223,10 @@ public class DhfsFileServiceImpl implements DhfsFileService {
|
|||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (chunksList.get().isEmpty()) {
|
||||||
|
return Optional.of(new byte[0]);
|
||||||
|
}
|
||||||
|
|
||||||
var chunks = chunksList.get().iterator();
|
var chunks = chunksList.get().iterator();
|
||||||
ByteBuffer buf = ByteBuffer.allocate(length);
|
ByteBuffer buf = ByteBuffer.allocate(length);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user