Skip to content

Commit a4ca365

Browse files
authored
fix:fix samefile logic error for s3+profile in sync (#548)
1 parent 2264e54 commit a4ca365

File tree

3 files changed

+8
-3
lines changed

3 files changed

+8
-3
lines changed

megfile/lib/compare.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55

66

77
def get_sync_type(src_protocol, dst_protocol):
8-
if src_protocol == "s3" and dst_protocol != "s3":
9-
return "download"
10-
elif src_protocol != "s3" and dst_protocol == "s3":
8+
if dst_protocol == "s3" or dst_protocol.startswith("s3+"):
119
return "upload"
10+
elif src_protocol == "s3" or src_protocol.startswith("s3+"):
11+
return "download"
1212
else:
1313
return "copy"
1414

megfile/s3_path.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -610,6 +610,7 @@ def create_generator(_s3_pathname) -> Iterator[FileEntry]:
610610
yield FileEntry(S3Path(path).name, path, _make_stat(content))
611611
dirname = os.path.dirname(path)
612612
while dirname not in dirnames and dirname != top_dir:
613+
# TODO: optimize memory usage and file path order
613614
dirnames.add(dirname)
614615
path = dirname + "/" if search_dir else dirname
615616
if pattern.match(path):

tests/utils/test_compare.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ def test_get_sync_type():
66
assert compare.get_sync_type("s3", "fs") == "download"
77
assert compare.get_sync_type("fs", "s3") == "upload"
88
assert compare.get_sync_type("sftp", "fs") == "copy"
9+
assert compare.get_sync_type("s3", "s3") == "upload"
10+
assert compare.get_sync_type("s3", "s3+test") == "upload"
11+
assert compare.get_sync_type("s3+test", "s3") == "upload"
12+
assert compare.get_sync_type("s3+test", "fs") == "download"
913

1014

1115
def test_compare_time():

0 commit comments

Comments
 (0)