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. 19
      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 virtual position (flushed + buffered)
// This represents where the next byte will be written
// Return current position (flushed + buffered)
return position + buffer.position();
}

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

@ -28,11 +28,6 @@ public class SeaweedRead {
int originalRemaining = buf.remaining();
List<ChunkView> chunkViews = viewFromVisibles(visibleIntervals, position, originalRemaining);
if (chunkViews.isEmpty()) {
}
Map<String, FilerProto.Locations> knownLocations = new HashMap<>();
@ -88,16 +83,16 @@ public class SeaweedRead {
}
} catch (Exception 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.
long limit = Math.min(position + originalRemaining, fileSize);
if (startOffset < limit) {
long gap = limit - startOffset;
@ -107,8 +102,6 @@ public class SeaweedRead {
startOffset += gap;
}
return readCount;
}
@ -262,8 +255,6 @@ public class SeaweedRead {
long chunksSize = totalSize(entry.getChunksList());
long attrSize = entry.getAttributes().getFileSize();
long finalSize = Math.max(chunksSize, attrSize);
LOG.info("Calculated file size: {} (chunks: {}, attr: {}, #chunks: {})",
finalSize, chunksSize, attrSize, entry.getChunksCount());
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);
return FilerProto.FileChunk.newBuilder()
.setFileId(fileId)
.setOffset(offset)
@ -143,14 +141,6 @@ public class SeaweedWrite {
synchronized (entry) {
List<FilerProto.FileChunk> chunks = FileChunkManifest.maybeManifestize(filerClient, entry.getChunksList(),
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.addAllChunks(chunks);

Loading…
Cancel
Save