XiaoHongbo-Hope commented on code in PR #7001:
URL: https://github.com/apache/paimon/pull/7001#discussion_r2687161247
##########
paimon-python/pypaimon/common/file_io.py:
##########
@@ -329,8 +353,13 @@ def copy_file(self, source_path: str, target_path: str,
overwrite: bool = False)
if not overwrite and self.exists(target_path):
raise FileExistsError(f"Target file {target_path} already exists
and overwrite=False")
- source_str = self.to_filesystem_path(source_path)
target_str = self.to_filesystem_path(target_path)
+ target_parent = Path(target_str).parent
+
+ if str(target_parent) and not self.exists(str(target_parent)):
+ self.mkdirs(str(target_parent))
+
+ source_str = self.to_filesystem_path(source_path)
Review Comment:
> The source path is converted to filesystem path (line 362) after the
target parent directory is potentially created (lines 356-360). If the source
path is invalid or to_filesystem_path raises an exception, the parent directory
for the target will have already been created unnecessarily. Consider
converting both source and target paths first before any filesystem operations.
fixed
--
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]