mirror of
https://github.com/usatiuk/dhfs.git
synced 2025-10-29 04:57:48 +01:00
little fixie 2
This commit is contained in:
@@ -494,6 +494,9 @@ public class DhfsFileServiceImpl implements DhfsFileService {
|
||||
if (!(fDataU instanceof File fData))
|
||||
throw new StatusRuntimeException(Status.INVALID_ARGUMENT);
|
||||
|
||||
if (size(fileUuid) < offset)
|
||||
truncate(fileUuid, offset);
|
||||
|
||||
var chunksAll = fData.getChunks();
|
||||
var first = chunksAll.floorEntry(offset);
|
||||
var last = chunksAll.lowerEntry(offset + data.length);
|
||||
|
||||
@@ -197,6 +197,22 @@ public class DhfsFileServiceSimpleTestImpl {
|
||||
Assertions.assertArrayEquals(new byte[]{}, fileService.read(uuid, 20, 10).get().toByteArray());
|
||||
}
|
||||
|
||||
@Test
|
||||
void writeOverSizeTest() {
|
||||
var ret = fileService.create("/writeOverSizeTest", 777);
|
||||
Assertions.assertTrue(ret.isPresent());
|
||||
var uuid = ret.get();
|
||||
|
||||
fileService.write(uuid, 0, new byte[]{0, 1, 2, 3, 4, 5, 6, 7, 8, 9});
|
||||
Assertions.assertArrayEquals(new byte[]{0, 1, 2, 3, 4, 5, 6, 7, 8, 9}, fileService.read(uuid, 0, 10).get().toByteArray());
|
||||
fileService.write(uuid, 20, new byte[]{10, 11, 12, 13, 14, 15, 16, 17, 18, 19});
|
||||
Assertions.assertArrayEquals(new byte[]{
|
||||
0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
10, 11, 12, 13, 14, 15, 16, 17, 18, 19
|
||||
}, fileService.read(uuid, 0, 30).get().toByteArray());
|
||||
}
|
||||
|
||||
@Test
|
||||
void moveTest2() throws InterruptedException {
|
||||
var ret = fileService.create("/moveTest", 777);
|
||||
|
||||
Reference in New Issue
Block a user