Copilot commented on code in PR #15208:
URL: https://github.com/apache/iotdb/pull/15208#discussion_r2018533963


##########
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/load/active/ActiveLoadTsFileLoader.java:
##########
@@ -195,27 +213,39 @@ private Optional<Pair<String, Boolean>> 
tryGetNextPendingFile() {
     }
   }
 
-  private TSStatus loadTsFile(final Pair<String, Boolean> filePair) throws 
FileNotFoundException {
+  private TSStatus loadTsFile(final Pair<String, Boolean> filePair, final 
IClientSession session)

Review Comment:
   The signature change for loadTsFile now requires all call sites to pass the 
session argument. Please ensure that all usages are updated accordingly and 
that unit tests cover the new behavior.



##########
iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/utils/FileUtils.java:
##########
@@ -405,6 +405,35 @@ public static void moveFileWithMD5Check(final File 
sourceFile, final File target
     }
   }
 
+  public static void copyFileWithMD5Check(final File sourceFile, final File 
targetDir)
+      throws IOException {
+    final String sourceFileName = sourceFile.getName();
+    final File targetFile = new File(targetDir, sourceFileName);
+    if (targetFile.exists()) {
+      if (!haveSameMD5(sourceFile, targetFile)) {
+        final String renameFile = copyFileRenameWithMD5(sourceFile, targetDir);
+        LOGGER.info(
+            "Copy file {} to {} because it already exists in the target 
directory: {}",
+            sourceFile.getName(),
+            renameFile,
+            targetDir.getAbsolutePath());
+      }
+    } else {
+      if (!(targetDir.exists() || targetDir.mkdirs())) {

Review Comment:
   The current directory creation check may not be robust in concurrent 
scenarios. Consider using Files.createDirectories for an atomic and more 
reliable directory creation.
   ```suggestion
         try {
           Files.createDirectories(targetDir.toPath());
         } catch (IOException e) {
   ```



-- 
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