]> code.citadel.org Git - citadel.git/blobdiff - citadel/file_ops.c
* partialy revert r8246; we're working in units of one here, so the number of units...
[citadel.git] / citadel / file_ops.c
index 21b7dfe835dcf60d390971b43c9f6cf3cd4663b9..ced5a31d568c3fef6f83466c7e51313abfdd4fbc 100644 (file)
@@ -549,7 +549,7 @@ void cmd_clos(char *cmdbuf)
 /*
  * abort an upload
  */
-void abort_upl(struct CitContext *who)
+void abort_upl(CitContext *who)
 {
        if (who->upload_fp != NULL) {
                fclose(who->upload_fp);
@@ -637,9 +637,15 @@ void cmd_read(char *cmdbuf)
        buf = malloc(bytes + 1);
 
        fseek(CC->download_fp, start_pos, 0);
+
        actual_bytes = fread(buf, 1, bytes, CC->download_fp);
-       cprintf("%d %d\n", BINARY_FOLLOWS, (int)actual_bytes);
-       client_write(buf, actual_bytes);
+       if (actual_bytes > 0) {
+               cprintf("%d %d\n", BINARY_FOLLOWS, (int)actual_bytes);
+               client_write(buf, bytes);
+       }
+       else {
+               cprintf("%d %s\n", ERROR, strerror(errno));
+       }
        free(buf);
 }