]> 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 b81ba6bed243fdcbea64209a1798cfba23d6c5a4..ced5a31d568c3fef6f83466c7e51313abfdd4fbc 100644 (file)
@@ -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);
 }