Browse Source

clean up

pull/7526/head
chrislu 1 week ago
parent
commit
d4bd0f8518
  1. 3
      other/java/client/src/main/java/seaweedfs/client/SeaweedOutputStream.java
  2. 17
      other/java/client/src/main/java/seaweedfs/client/SeaweedRead.java
  3. 10
      other/java/client/src/main/java/seaweedfs/client/SeaweedWrite.java

3
other/java/client/src/main/java/seaweedfs/client/SeaweedOutputStream.java

@ -100,8 +100,7 @@ public class SeaweedOutputStream extends OutputStream {
return position; return position;
} }
// Return virtual position (flushed + buffered)
// This represents where the next byte will be written
// Return current position (flushed + buffered)
return position + buffer.position(); return position + buffer.position();
} }

17
other/java/client/src/main/java/seaweedfs/client/SeaweedRead.java

@ -29,11 +29,6 @@ public class SeaweedRead {
int originalRemaining = buf.remaining(); int originalRemaining = buf.remaining();
List<ChunkView> chunkViews = viewFromVisibles(visibleIntervals, position, originalRemaining); List<ChunkView> chunkViews = viewFromVisibles(visibleIntervals, position, originalRemaining);
if (chunkViews.isEmpty()) {
}
Map<String, FilerProto.Locations> knownLocations = new HashMap<>(); Map<String, FilerProto.Locations> knownLocations = new HashMap<>();
FilerProto.LookupVolumeRequest.Builder lookupRequest = FilerProto.LookupVolumeRequest.newBuilder(); FilerProto.LookupVolumeRequest.Builder lookupRequest = FilerProto.LookupVolumeRequest.newBuilder();
@ -92,13 +87,13 @@ public class SeaweedRead {
throw e; throw e;
} }
// Fix: Calculate the correct limit based on the read position and requested size,
// not the buffer's absolute limit. This fixes the 78-byte EOF error when seeking
// Fix: Calculate the correct limit based on the read position and requested
// size,
// not the buffer's absolute limit. This fixes the 78-byte EOF error when
// seeking
// near the end of the file. // near the end of the file.
long limit = Math.min(position + originalRemaining, fileSize); long limit = Math.min(position + originalRemaining, fileSize);
if (startOffset < limit) { if (startOffset < limit) {
long gap = limit - startOffset; long gap = limit - startOffset;
LOG.debug("zero2 [{},{})", startOffset, startOffset + gap); LOG.debug("zero2 [{},{})", startOffset, startOffset + gap);
@ -107,8 +102,6 @@ public class SeaweedRead {
startOffset += gap; startOffset += gap;
} }
return readCount; return readCount;
} }
@ -262,8 +255,6 @@ public class SeaweedRead {
long chunksSize = totalSize(entry.getChunksList()); long chunksSize = totalSize(entry.getChunksList());
long attrSize = entry.getAttributes().getFileSize(); long attrSize = entry.getAttributes().getFileSize();
long finalSize = Math.max(chunksSize, attrSize); long finalSize = Math.max(chunksSize, attrSize);
LOG.info("Calculated file size: {} (chunks: {}, attr: {}, #chunks: {})",
finalSize, chunksSize, attrSize, entry.getChunksCount());
return finalSize; return finalSize;
} }

10
other/java/client/src/main/java/seaweedfs/client/SeaweedWrite.java

@ -125,8 +125,6 @@ public class SeaweedWrite {
String etag = multipartUpload(targetUrl, auth, bytes, bytesOffset, bytesLength, cipherKey); String etag = multipartUpload(targetUrl, auth, bytes, bytesOffset, bytesLength, cipherKey);
return FilerProto.FileChunk.newBuilder() return FilerProto.FileChunk.newBuilder()
.setFileId(fileId) .setFileId(fileId)
.setOffset(offset) .setOffset(offset)
@ -143,14 +141,6 @@ public class SeaweedWrite {
synchronized (entry) { synchronized (entry) {
List<FilerProto.FileChunk> chunks = FileChunkManifest.maybeManifestize(filerClient, entry.getChunksList(), List<FilerProto.FileChunk> chunks = FileChunkManifest.maybeManifestize(filerClient, entry.getChunksList(),
parentDirectory); parentDirectory);
long totalSize = 0;
for (FilerProto.FileChunk chunk : chunks) {
totalSize = Math.max(totalSize, chunk.getOffset() + chunk.getSize());
}
// Check if there's a size mismatch with attributes
long attrFileSize = entry.getAttributes().getFileSize();
entry.clearChunks(); entry.clearChunks();
entry.addAllChunks(chunks); entry.addAllChunks(chunks);

Loading…
Cancel
Save