mirror of
https://github.com/upa/mscp.git
synced 2026-02-04 03:24:58 +08:00
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.
This commit is contained in:
@@ -72,8 +72,8 @@ MDIR *mscp_opendir(const char *path, sftp_session sftp)
|
|||||||
return NULL;
|
return NULL;
|
||||||
memset(md, 0, sizeof(*md));
|
memset(md, 0, sizeof(*md));
|
||||||
|
|
||||||
if (tls_sftp) {
|
if (sftp) {
|
||||||
md->remote = sftp_opendir(tls_sftp, path);
|
md->remote = sftp_opendir(sftp, path);
|
||||||
sftp_err_to_errno(sftp);
|
sftp_err_to_errno(sftp);
|
||||||
if (!md->remote) {
|
if (!md->remote) {
|
||||||
goto free_out;
|
goto free_out;
|
||||||
@@ -146,8 +146,6 @@ int mscp_mkdir(const char *path, mode_t mode, sftp_session sftp)
|
|||||||
|
|
||||||
if (sftp) {
|
if (sftp) {
|
||||||
ret = sftp_mkdir(sftp, path, mode);
|
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);
|
sftp_err_to_errno(sftp);
|
||||||
} else
|
} else
|
||||||
ret = mkdir(path, mode);
|
ret = mkdir(path, mode);
|
||||||
|
|||||||
@@ -11,11 +11,15 @@ from util import File, check_same_md5sum
|
|||||||
|
|
||||||
|
|
||||||
def run2ok(args):
|
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):
|
def run2ng(args):
|
||||||
|
cmd = list(map(str, args))
|
||||||
|
print("cmd: {}".format(" ".join(cmd)))
|
||||||
with pytest.raises(CalledProcessError) as e:
|
with pytest.raises(CalledProcessError) as e:
|
||||||
check_call(list(map(str, args)))
|
check_call(cmd)
|
||||||
|
|
||||||
|
|
||||||
""" usage test """
|
""" usage test """
|
||||||
@@ -127,6 +131,23 @@ def test_dir_copy(mscp, src_prefix, dst_prefix, src_dir, dst_dir, src, dst, twic
|
|||||||
df.cleanup()
|
df.cleanup()
|
||||||
tf.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)
|
@pytest.mark.parametrize("src_prefix, dst_prefix", param_remote_prefix)
|
||||||
def test_override_single_file(mscp, src_prefix, dst_prefix):
|
def test_override_single_file(mscp, src_prefix, dst_prefix):
|
||||||
src = File("src", size = 128).make()
|
src = File("src", size = 128).make()
|
||||||
|
|||||||
Reference in New Issue
Block a user