Skip to content

Commit

Permalink
Simple fix for github issue gridcf#3
Browse files Browse the repository at this point in the history
This is a simple and not very clean fix for
gridcf/issues/3
Either (one of) the l_write() or the l_close() can fail if the remote file
already exists, since the data goes over a different channel than the control
messages. For large files, it will typically be one of the later l_write()
statements, for small files probably the l_close(). Hence we effectively only
have the errmsg to find out what happened, and therefore do a simple str(n)cmp
with this errmsg. For this we also need to add a function to get it from the
opaque errcode_t.
  • Loading branch information
msalle committed May 20, 2020
1 parent 012788f commit 450e2e0
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
6 changes: 6 additions & 0 deletions cmds.c
Original file line number Diff line number Diff line change
Expand Up @@ -3530,6 +3530,12 @@ _c_xfer_file(ch_t * sch,
if (ecl || ecr || ec)
cr = CMD_ERR_GET;

if (ec && strncmp(ec_get_errmsg(ec), "550 File exists", 15) == 0 ||
ecr && strncmp(ec_get_errmsg(ecr),"550 File exists", 15) == 0)
{
delfile=0;
}

ec_print(ec);
ec_destroy(ec);

Expand Down
5 changes: 5 additions & 0 deletions errcode.c
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,11 @@ ec_destroy(errcode_t errcode)
return;
}

char
*ec_get_errmsg(errcode_t errcode)
{
return (errcode ? *(errcode->errmsg) : "");
}

void
ec_print(errcode_t errcode)
Expand Down
3 changes: 3 additions & 0 deletions errcode.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@

typedef struct errcode_s * errcode_t;

char *
ec_get_errmsg(errcode_t errcode);

errcode_t
ec_create(OM_uint32, OM_uint32, char * fmt, ...);

Expand Down

0 comments on commit 450e2e0

Please sign in to comment.