Skip to content

Commit

Permalink
fix clone to keep original (#2755)
Browse files Browse the repository at this point in the history
  • Loading branch information
yanchengnv authored Aug 2, 2024
1 parent fcf8eea commit 6f500dc
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion nvflare/app_common/storages/filesystem_storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,20 @@


def _write(path: str, content, mv_file=True):
"""Create a file at the specified 'path' with the specified 'content'.
Args:
path: the path of the file to be created
content: content for the file to be created. It could be either bytes, or path (str) to the source file that
contains the content.
mv_file: whether the destination file should be created simply by moving the source file. This is applicable
only when the 'content' is the path of the source file. If mv_file is False, the destination is created
by copying from the source file, and the source file will remain intact; If mv_file is True, the
destination file is created by "move" the source file, and the original source file will no longer exist.
Returns:
"""
tmp_path = path + "_" + str(uuid.uuid4())
try:
Path(os.path.dirname(path)).mkdir(parents=True, exist_ok=True)
Expand Down Expand Up @@ -162,7 +176,7 @@ def clone_object(self, from_uri: str, to_uri: str, meta: dict, overwrite_existin

from_full_uri = self._object_path(from_uri)
from_data_path = os.path.join(from_full_uri, DATA)
_write(data_path, from_data_path)
_write(data_path, from_data_path, mv_file=False)

meta_path = os.path.join(full_uri, META)
try:
Expand Down

0 comments on commit 6f500dc

Please sign in to comment.