mirror of
https://github.com/upa/mscp.git
synced 2026-02-18 20:34:59 +08:00
fix dst path resolve
This commit is contained in:
11
src/mscp.c
11
src/mscp.c
@@ -297,7 +297,7 @@ int mscp_set_dst_path(struct mscp *m, const char *dst_path)
|
||||
int mscp_prepare(struct mscp *m)
|
||||
{
|
||||
sftp_session src_sftp = NULL, dst_sftp = NULL;
|
||||
bool src_path_is_dir, dst_path_is_dir;
|
||||
bool src_path_is_dir, dst_path_is_dir, dst_path_should_dir = false;
|
||||
struct list_head tmp;
|
||||
struct src *s;
|
||||
mstat ss, ds;
|
||||
@@ -316,6 +316,9 @@ int mscp_prepare(struct mscp *m)
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (list_count(&m->src_list) > 1)
|
||||
dst_path_should_dir = true;
|
||||
|
||||
if (mscp_stat(m->dst_path, &ds, dst_sftp) == 0) {
|
||||
if (mstat_is_dir(ds))
|
||||
dst_path_is_dir = true;
|
||||
@@ -336,8 +339,12 @@ int mscp_prepare(struct mscp *m)
|
||||
if (walk_src_path(src_sftp, s->path, &tmp) < 0)
|
||||
return -1;
|
||||
|
||||
if (list_count(&tmp) > 1)
|
||||
dst_path_should_dir = true;
|
||||
|
||||
if (resolve_dst_path(s->path, m->dst_path, &tmp,
|
||||
src_path_is_dir, dst_path_is_dir) < 0)
|
||||
src_path_is_dir, dst_path_is_dir,
|
||||
dst_path_should_dir) < 0)
|
||||
return -1;
|
||||
|
||||
list_splice_tail(&tmp, m->path_list.prev);
|
||||
|
||||
Reference in New Issue
Block a user