Jason918 commented on code in PR #15412:
URL: https://github.com/apache/pulsar/pull/15412#discussion_r863791836


##########
pulsar-metadata/src/main/java/org/apache/pulsar/metadata/impl/RocksdbMetadataStore.java:
##########
@@ -220,6 +223,8 @@ private RocksdbMetadataStore(String metadataURL, 
MetadataStoreConfig metadataSto
         Path dataPath = FileSystems.getDefault().getPath(dataDir);
         try {
             Files.createDirectories(dataPath);
+            Set<PosixFilePermission> perms = 
PosixFilePermissions.fromString("rwx------");

Review Comment:
   Not in the scope of this PR.



##########
pulsar-common/src/main/java/org/apache/pulsar/common/nar/NarUnpacker.java:
##########
@@ -175,4 +180,51 @@ private static byte[] calculateMd5sum(final File file) 
throws IOException {
             throw new IllegalArgumentException(nsae);
         }
     }
+
+    private static boolean setPosixFilePermissions(File file, String perm) 
throws IOException {
+        Set<PosixFilePermission> perms = PosixFilePermissions.fromString(perm);
+        try {
+            Files.setPosixFilePermissions(file.toPath(), perms);
+            log.info("Set permissions on " + file.getAbsolutePath() + " with 
permission " + perm);
+            return true;
+        } catch (IOException e) {
+            log.warn("Failed to set file permissions on " + 
file.getAbsolutePath());
+            return false;
+        }
+    }
+
+    private static boolean createDirWithSpecialPermission(File file, String 
permission, boolean createParent)
+            throws IOException {
+        if (file.exists()) {
+            log.warn("Directory " + file.toString() + " exist.");
+            return false;
+        }
+        try {
+            if (createParent) {
+                File parent = file.getParentFile();
+                if (parent == null) {
+                    log.warn("Parent File is null");
+                    return false;
+                }
+                parent.mkdirs();
+            }
+            file.mkdir();

Review Comment:
   ```suggestion
               if (createParent) {
                  file.mkdirs();
               } else {
                  file.mkdir();
               }
   ```
   This is simpler? 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to