diff options
author | Ryo Nakamura <upa@haeena.net> | 2023-08-30 19:09:29 +0900 |
---|---|---|
committer | Ryo Nakamura <upa@haeena.net> | 2023-08-30 19:09:29 +0900 |
commit | 13ec6521957ab0faadff36353d1ff3c8e0ac03ce (patch) | |
tree | e832e996d198a37531983d1d41629580141401ed | |
parent | 6b45cf7c9ccbdcb75f150d060652ef9e9d5f2dd4 (diff) |
fix mscp_opendir, do not use `tls_sftp`, use `sftp` isntead.
The fixed issue causes mscp_opendir wrongly calls opendir() for
local when tls_sftp is NULL although sftp is not NULL.
-rw-r--r-- | src/fileops.c | 6 | ||||
-rw-r--r-- | test/test_e2e.py | 25 |
2 files changed, 25 insertions, 6 deletions
diff --git a/src/fileops.c b/src/fileops.c index d9587ef..39d0801 100644 --- a/src/fileops.c +++ b/src/fileops.c @@ -72,8 +72,8 @@ MDIR *mscp_opendir(const char *path, sftp_session sftp) return NULL; memset(md, 0, sizeof(*md)); - if (tls_sftp) { - md->remote = sftp_opendir(tls_sftp, path); + if (sftp) { + md->remote = sftp_opendir(sftp, path); sftp_err_to_errno(sftp); if (!md->remote) { goto free_out; @@ -146,8 +146,6 @@ int mscp_mkdir(const char *path, mode_t mode, sftp_session sftp) if (sftp) { ret = sftp_mkdir(sftp, path, mode); - fprintf(stderr, "after sftp_mkdir(%s), sftp_get_error is %d\n", - path, sftp_get_error(sftp)); sftp_err_to_errno(sftp); } else ret = mkdir(path, mode); diff --git a/test/test_e2e.py b/test/test_e2e.py index c63a09e..108ae71 100644 --- a/test/test_e2e.py +++ b/test/test_e2e.py @@ -11,11 +11,15 @@ from util import File, check_same_md5sum def run2ok(args): - check_call(list(map(str, args))) + cmd = list(map(str, args)) + print("cmd: {}".format(" ".join(cmd))) + check_call(cmd) def run2ng(args): + cmd = list(map(str, args)) + print("cmd: {}".format(" ".join(cmd))) with pytest.raises(CalledProcessError) as e: - check_call(list(map(str, args))) + check_call(cmd) """ usage test """ @@ -127,6 +131,23 @@ def test_dir_copy(mscp, src_prefix, dst_prefix, src_dir, dst_dir, src, dst, twic df.cleanup() tf.cleanup() + +param_dir_copy_single = [ + ("src_dir", "dst_dir", + File("src_dir/t1", size = 1024 * 1024), + File("dst_dir/src_dir/t1"), + ) +] +@pytest.mark.parametrize("src_prefix, dst_prefix", param_remote_prefix) +@pytest.mark.parametrize("src_dir, dst_dir, src, dst", param_dir_copy_single) +def test_dir_copy_single(mscp, src_prefix, dst_prefix, src_dir, dst_dir, src, dst): + src.make() + os.mkdir(dst_dir) + run2ok(["mscp", "-H", "-vvv", src_prefix + src_dir, dst_prefix + dst_dir]) + assert check_same_md5sum(src, dst) + src.cleanup() + dst.cleanup() + @pytest.mark.parametrize("src_prefix, dst_prefix", param_remote_prefix) def test_override_single_file(mscp, src_prefix, dst_prefix): src = File("src", size = 128).make() |