/* Close data connection socket. */
closeport (dtsock);
/* Close the local file. */
- if (!opt.dfp || con->cmd & DO_LIST)
- fclose (fp);
- else
- fflush (fp);
+ {
+ /* Close or flush the file. We have to be careful to check for
+ error here. Checking the result of fwrite() is not enough --
+ errors could go unnoticed! */
+ int flush_res;
+ if (!opt.dfp || con->cmd & DO_LIST)
+ flush_res = fclose (fp);
+ else
+ flush_res = fflush (fp);
+ if (flush_res == EOF)
+ res = -2;
+ }
/* If get_contents couldn't write to fp, bail out. */
if (res == -2)
{
/* Increase the depth. */
++depth;
- if (opt.reclevel && depth > opt.reclevel)
+ if (opt.reclevel != INFINITE_RECURSION && depth > opt.reclevel)
{
DEBUGP ((_("Recursion depth %d exceeded max. depth %d.\n"),
depth, opt.reclevel));
else if (f->tstamp == -1)
logprintf (LOG_NOTQUIET, _("%s: corrupt time-stamp.\n"), u->local);
- if (f->perms && dlthis)
+ if (f->perms && f->type == FT_PLAINFILE && dlthis)
chmod (u->local, f->perms);
else
DEBUGP (("Unrecognized permissions for %s.\n", u->local));
f = f->next;
} /* while */
/* We do not want to call ftp_retrieve_dirs here */
- if (opt.recursive && !(opt.reclevel && depth >= opt.reclevel))
+ if (opt.recursive &&
+ !(opt.reclevel != INFINITE_RECURSION && depth >= opt.reclevel))
err = ftp_retrieve_dirs (u, orig, con);
else if (opt.recursive)
DEBUGP ((_("Will not retrieve dirs since depth is %d (max %d).\n"),