diff --git a/other/java/client/src/main/java/seaweedfs/client/SeaweedRead.java b/other/java/client/src/main/java/seaweedfs/client/SeaweedRead.java index cac85d186..dbade3408 100644 --- a/other/java/client/src/main/java/seaweedfs/client/SeaweedRead.java +++ b/other/java/client/src/main/java/seaweedfs/client/SeaweedRead.java @@ -239,7 +239,12 @@ public class SeaweedRead { } public static long fileSize(FilerProto.Entry entry) { - return Math.max(totalSize(entry.getChunksList()), entry.getAttributes().getFileSize()); + 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; } public static long totalSize(List chunksList) { diff --git a/other/java/client/src/main/java/seaweedfs/client/SeaweedWrite.java b/other/java/client/src/main/java/seaweedfs/client/SeaweedWrite.java index 5d4375d0f..d83245363 100644 --- a/other/java/client/src/main/java/seaweedfs/client/SeaweedWrite.java +++ b/other/java/client/src/main/java/seaweedfs/client/SeaweedWrite.java @@ -125,7 +125,7 @@ public class SeaweedWrite { String etag = multipartUpload(targetUrl, auth, bytes, bytesOffset, bytesLength, cipherKey); - LOG.debug("write file chunk {} size {}", targetUrl, bytesLength); + LOG.info("✓ Wrote chunk to {} at offset {} size {} bytes, etag: {}", targetUrl, offset, bytesLength, etag); return FilerProto.FileChunk.newBuilder() .setFileId(fileId) @@ -143,6 +143,12 @@ public class SeaweedWrite { synchronized (entry) { List chunks = FileChunkManifest.maybeManifestize(filerClient, entry.getChunksList(), parentDirectory); + long totalSize = 0; + for (FilerProto.FileChunk chunk : chunks) { + totalSize = Math.max(totalSize, chunk.getOffset() + chunk.getSize()); + } + LOG.info("✓ Writing metadata to {} with {} chunks, total size: {} bytes", + parentDirectory + "/" + entry.getName(), chunks.size(), totalSize); entry.clearChunks(); entry.addAllChunks(chunks); filerClient.getBlockingStub().createEntry(