Re: uploaded files different size
Joe Orton <[email protected]>
| Newsgroups | gmane.comp.web.sitecopy |
|---|---|
| Message-ID | <[email protected]> |
Please keep the CC [email protected]. Yes, there are a couple of issues like this with sitecopy's newline translation; I can't remember why. Here's what I propose to use instead for future versions, can you try out the patch? Index: src/ftp.c =================================================================== --- src/ftp.c (revision 531) +++ src/ftp.c (working copy) @@ -421,33 +421,27 @@ * (in which case, session error string is set). */ static int send_file_ascii(ftp_session *sess, FILE *f, off_t fsize) { - int ret; - char buffer[BUFSIZ], *pnt; + char buffer[BUFSIZ]; off_t total = 0, lasttotal = 0; while (fgets(buffer, BUFSIZ - 1, f) != NULL) { - /* Ensure that line-ending is CRLF. */ - pnt = strchr(buffer, '\r'); - if (pnt == NULL) { - /* We need to add the CR in */ - pnt = strchr(buffer, '\n'); - if (pnt == NULL) { - /* No CRLF; last line of file */ - pnt = memchr(buffer, '\0', sizeof buffer); - assert(pnt != NULL); - } - /* Now, pnt points to the first character after the - * end of the line, i.e., where we want to put the CR. - */ - *pnt++ = '\r'; - /* And lob in an LF afterwards */ - *pnt-- = '\n'; - } - /* At this point, pnt points to the CR. - * We send everything between pnt and the beginning of the buffer, - * +2 for the CRLF - */ - ret = ne_sock_fullwrite(sess->dtpsock, buffer, 2 + pnt - buffer); + size_t buflen; + char *pnt; + int ret; + + /* if there is an LF terminator, turn that into a CRLF; + * otherwise just send the whole line as-is. */ + pnt = strchr(buffer, '\n'); + if (pnt) { + *pnt++ = '\r'; + *pnt++ = '\n'; + buflen = pnt - buffer; + } else { + /* line with no CRLF. */ + buflen = strlen(buffer); + } + + ret = ne_sock_fullwrite(sess->dtpsock, buffer, buflen); if (ret) { set_sockerr(sess, sess->dtpsock, _("Error sending file"), ret); return -1; _______________________________________________ sitecopy maillist - [email protected] http://dav.lyra.org/mailman/listinfo/sitecopy