Commit Diff


commit - 1cd5d437cd303d5c73dd23294496c760a641f7ca
commit + ea1b5cf5005faca9f93f85077f7758697a39c622
blob - c86f07553d7eb1c99193170a4649f32df77eedc3
blob + 9abf39da83bf1be247e7a193dbd862538fbc98e1
--- gotwebd/got_operations.c
+++ gotwebd/got_operations.c
@@ -952,48 +952,6 @@ got_open_blob_for_output(struct got_blob_object **blob
 	free(in_repo_path);
 	free(commit_id);
 	free(path);
-	return error;
-}
-
-const struct got_error *
-got_output_file_blob(struct request *c)
-{
-	const struct got_error *error = NULL;
-	struct querystring *qs = c->t->qs;
-	struct got_blob_object *blob = NULL;
-	size_t len;
-	int binary, fd = -1;
-	const uint8_t *buf;
-
-	error = got_open_blob_for_output(&blob, &fd, &binary, c);
-	if (error)
-		return error;
-
-	if (binary)
-		error = gotweb_render_content_type_file(c,
-		    "application/octet-stream", qs->file, NULL);
-	else
-		error = gotweb_render_content_type(c, "text/plain");
-
-	if (error) {
-		log_warnx("%s: %s", __func__, error->msg);
-		goto done;
-	}
-
-	for (;;) {
-		error = got_object_blob_read_block(&len, blob);
-		if (error)
-			goto done;
-		if (len == 0)
-			break;
-		buf = got_object_blob_get_read_buf(blob);
-		fcgi_gen_binary_response(c, buf, len);
-	}
- done:
-	if (close(fd) == -1 && error == NULL)
-		error = got_error_from_errno("close");
-	if (blob)
-		got_object_blob_close(blob);
 	return error;
 }
 
blob - f1b36bfe4953cf0397b23423bd71b0801f678f65
blob + bff6367b04a8ed87a09a78c9afbc95a0fbea44c5
--- gotwebd/gotweb.c
+++ gotwebd/gotweb.c
@@ -169,14 +169,40 @@ gotweb_process_request(struct request *c)
 	}
 
 	if (qs->action == BLOBRAW) {
+		const uint8_t *buf;
+		size_t len;
+		int binary;
+
 		error = got_get_repo_commits(c, 1);
 		if (error)
 			goto done;
-		error = got_output_file_blob(c);
+
+		error2 = got_open_blob_for_output(&blob, &fd, &binary, c);
+		if (error2)
+			goto render;
+
+		if (binary)
+			error = gotweb_render_content_type_file(c,
+			    "application/octet-stream", qs->file, NULL);
+		else
+			error = gotweb_render_content_type(c, "text/plain");
+
 		if (error) {
 			log_warnx("%s: %s", __func__, error->msg);
-			goto err;
+			goto done;
+		}
+
+		for (;;) {
+			error = got_object_blob_read_block(&len, blob);
+			if (error)
+				goto done;
+			if (len == 0)
+				break;
+			buf = got_object_blob_get_read_buf(blob);
+			if (fcgi_gen_binary_response(c, buf, len) == -1)
+				goto done;
 		}
+
 		goto done;
 	}
 
blob - b763c41784157572b726d047cb45a220b60c30fb
blob + 9a1da08f309eb5fd956f60c275b48bd8c41bbbe0
--- gotwebd/gotwebd.h
+++ gotwebd/gotwebd.h
@@ -522,7 +522,6 @@ int got_output_repo_tree(struct request *,
     int (*)(struct template *, struct got_tree_entry *));
 const struct got_error *got_open_blob_for_output(struct got_blob_object **,
     int *, int *, struct request *);
-const struct got_error *got_output_file_blob(struct request *);
 int got_output_blob_by_lines(struct template *, struct got_blob_object *,
     int (*)(struct template *, const char *, size_t));
 const struct got_error *got_output_file_blame(struct request *,