aboutsummaryrefslogtreecommitdiff
path: root/other/java/client/src
diff options
context:
space:
mode:
authorChris Lu <chris.lu@gmail.com>2021-05-06 11:38:23 -0700
committerChris Lu <chris.lu@gmail.com>2021-05-06 11:38:23 -0700
commit9b5f54e36733854fc8d6897808ce53349cf7b785 (patch)
tree4f8604b1fef8c46d82f1a8a9b50ec91491ccba63 /other/java/client/src
parent28d58bac62a2721261dca9e0e90525eba272b02c (diff)
downloadseaweedfs-9b5f54e36733854fc8d6897808ce53349cf7b785.tar.xz
seaweedfs-9b5f54e36733854fc8d6897808ce53349cf7b785.zip
java: filer client add modified time to touch() function
Diffstat (limited to 'other/java/client/src')
-rw-r--r--other/java/client/src/main/java/seaweedfs/client/FilerClient.java40
1 files changed, 24 insertions, 16 deletions
diff --git a/other/java/client/src/main/java/seaweedfs/client/FilerClient.java b/other/java/client/src/main/java/seaweedfs/client/FilerClient.java
index 257a9873d..91e7cba57 100644
--- a/other/java/client/src/main/java/seaweedfs/client/FilerClient.java
+++ b/other/java/client/src/main/java/seaweedfs/client/FilerClient.java
@@ -142,10 +142,12 @@ public class FilerClient extends FilerGrpcClient {
public boolean touch(String path, int mode) {
String currentUser = System.getProperty("user.name");
- return touch(path, mode, 0, 0, currentUser, new String[]{});
+
+ long now = System.currentTimeMillis() / 1000L;
+ return touch(path, now, mode, 0, 0, currentUser, new String[]{});
}
- public boolean touch(String path, int mode, int uid, int gid, String userName, String[] groupNames) {
+ public boolean touch(String path, long modifiedTimeSecond, int mode, int uid, int gid, String userName, String[] groupNames) {
File pathFile = new File(path);
String parent = pathFile.getParent().replace('\\','/');
@@ -155,17 +157,25 @@ public class FilerClient extends FilerGrpcClient {
if (entry == null) {
return createEntry(
parent,
- newFileEntry(name, mode, uid, gid, userName, groupNames).build()
+ newFileEntry(name, modifiedTimeSecond, mode, uid, gid, userName, groupNames).build()
);
}
- long now = System.currentTimeMillis() / 1000L;
- FilerProto.FuseAttributes.Builder attr = entry.getAttributes().toBuilder()
- .setMtime(now)
- .setUid(uid)
- .setGid(gid)
- .setUserName(userName)
- .clearGroupName()
- .addAllGroupName(Arrays.asList(groupNames));
+ FilerProto.FuseAttributes.Builder attr = entry.getAttributes().toBuilder();
+ if (modifiedTimeSecond>0) {
+ attr.setMtime(modifiedTimeSecond);
+ }
+ if (uid>0) {
+ attr.setUid(uid);
+ }
+ if (gid>0) {
+ attr.setGid(gid);
+ }
+ if (userName!=null) {
+ attr.setUserName(userName);
+ }
+ if (groupNames!=null) {
+ attr.clearGroupName().addAllGroupName(Arrays.asList(groupNames));
+ }
return updateEntry(parent, entry.toBuilder().setAttributes(attr).build());
}
@@ -188,17 +198,15 @@ public class FilerClient extends FilerGrpcClient {
.addAllGroupName(Arrays.asList(groupNames)));
}
- public FilerProto.Entry.Builder newFileEntry(String name, int mode,
+ public FilerProto.Entry.Builder newFileEntry(String name, long modifiedTimeSecond, int mode,
int uid, int gid, String userName, String[] groupNames) {
- long now = System.currentTimeMillis() / 1000L;
-
return FilerProto.Entry.newBuilder()
.setName(name)
.setIsDirectory(false)
.setAttributes(FilerProto.FuseAttributes.newBuilder()
- .setMtime(now)
- .setCrtime(now)
+ .setMtime(modifiedTimeSecond)
+ .setCrtime(modifiedTimeSecond)
.setUid(uid)
.setGid(gid)
.setFileMode(mode)