diff --git a/HISTORY b/HISTORY index 21eabb3..c3d13f3 100644 --- a/HISTORY +++ b/HISTORY @@ -1,4 +1,10 @@ +Version 1.37 2025-11-06 + * query file info support two combined flags: + ProtoCommon.FDFS_QUERY_FINFO_FLAGS_NOT_CALC_CRC32 + ProtoCommon.FDFS_QUERY_FINFO_FLAGS_KEEP_SILENCE + you must upgrade your FastDFS server V6.15.1 and higher version + Version 1.36 2025-10-26 * monitor protocol compatible with IPv4/IPv6 address automatically * FastDFS server version requirements: diff --git a/pom.xml b/pom.xml index d234c28..cb8f62b 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ org.csource fastdfs-client-java - 1.36-SNAPSHOT + 1.37-SNAPSHOT fastdfs-client-java fastdfs client for java jar diff --git a/src/main/java/org/csource/fastdfs/ProtoCommon.java b/src/main/java/org/csource/fastdfs/ProtoCommon.java index 889341b..0b06c5e 100644 --- a/src/main/java/org/csource/fastdfs/ProtoCommon.java +++ b/src/main/java/org/csource/fastdfs/ProtoCommon.java @@ -113,6 +113,9 @@ public class ProtoCommon { public static final byte FDFS_RW_MODE_WRITEONLY = 2; public static final byte FDFS_RW_MODE_BOTH = FDFS_RW_MODE_READONLY + FDFS_RW_MODE_WRITEONLY; + public static final byte FDFS_QUERY_FINFO_FLAGS_NOT_CALC_CRC32 = 1; + public static final byte FDFS_QUERY_FINFO_FLAGS_KEEP_SILENCE = 2; + private ProtoCommon() { } diff --git a/src/main/java/org/csource/fastdfs/StorageClient.java b/src/main/java/org/csource/fastdfs/StorageClient.java index cd2f26d..fb808fe 100644 --- a/src/main/java/org/csource/fastdfs/StorageClient.java +++ b/src/main/java/org/csource/fastdfs/StorageClient.java @@ -1540,9 +1540,14 @@ public class StorageClient { * * @param group_name the group name of storage server * @param remote_filename filename on storage server + * @param flags combined flags as following: + * ProtoCommon.FDFS_QUERY_FINFO_FLAGS_NOT_CALC_CRC32 : do NOT calculate CRC32 + * for appender file or slave file + * ProtoCommon.FDFS_QUERY_FINFO_FLAGS_KEEP_SILENCE : keep silence, + * when this file not exist, do not log error on storage server * @return FileInfo object for success, return null for fail */ - public FileInfo query_file_info(String group_name, String remote_filename) throws IOException, MyException { + public FileInfo query_file_info(String group_name, String remote_filename, byte flags) throws IOException, MyException { boolean bNewStorageServer = this.newUpdatableStorageConnection(group_name, remote_filename); Connection connection = this.storageServer.getConnection(); try { @@ -1566,7 +1571,7 @@ public class StorageClient { System.arraycopy(bs, 0, groupBytes, 0, groupLen); header = ProtoCommon.packHeader(ProtoCommon.STORAGE_PROTO_CMD_QUERY_FILE_INFO, - +groupBytes.length + filenameBytes.length, (byte) 0); + groupBytes.length + filenameBytes.length, flags); OutputStream out = connection.getOutputStream(); byte[] wholePkg = new byte[header.length + groupBytes.length + filenameBytes.length]; System.arraycopy(header, 0, wholePkg, 0, header.length); @@ -1613,6 +1618,11 @@ public class StorageClient { } } + public FileInfo query_file_info(String group_name, String remote_filename) throws IOException, MyException { + final byte flags = 0; + return this.query_file_info(group_name, remote_filename, flags); + } + /** * check storage socket, if null create a new connection * diff --git a/src/main/java/org/csource/fastdfs/StorageClient1.java b/src/main/java/org/csource/fastdfs/StorageClient1.java index 50004eb..0063ee9 100644 --- a/src/main/java/org/csource/fastdfs/StorageClient1.java +++ b/src/main/java/org/csource/fastdfs/StorageClient1.java @@ -735,16 +735,26 @@ public class StorageClient1 extends StorageClient { * get file info from storage server * * @param file_id the file id(including group name and filename) + * @param flags combined flags as following: + * ProtoCommon.FDFS_QUERY_FINFO_FLAGS_NOT_CALC_CRC32 : do NOT calculate CRC32 + * for appender file or slave file + * ProtoCommon.FDFS_QUERY_FINFO_FLAGS_KEEP_SILENCE : keep silence, + * when this file not exist, do not log error on storage server * @return FileInfo object for success, return null for fail */ - public FileInfo query_file_info1(String file_id) throws IOException, MyException { - String[] parts = new String[2]; - this.errno = this.split_file_id(file_id, parts); - if (this.errno != 0) { - return null; - } + public FileInfo query_file_info1(String file_id, byte flags) throws IOException, MyException { + String[] parts = new String[2]; + this.errno = this.split_file_id(file_id, parts); + if (this.errno != 0) { + return null; + } - return this.query_file_info(parts[0], parts[1]); + return this.query_file_info(parts[0], parts[1], flags); + } + + public FileInfo query_file_info1(String file_id) throws IOException, MyException { + final byte flags = 0; + return this.query_file_info1(file_id, flags); } /**