Commit Diff


commit - 8319855fa7affdb1199a46d76f87b9fec409eb81
commit + 760079985fc2d63ebd4155a76d4f0d20fbc2f4c5
blob - 378b693e64c01e80488c24a7dedd69cc0b8e53e0
blob + 63fc429b8a15be040dbfbb4a339c47974a9d29e6
--- 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 - 9571e03a832b18e48cc16b0c1904e3b0d2d687b5
blob + f130435179a5b33ae9f100337a219e97ce5607aa
--- gotwebd/gotweb.c
+++ gotwebd/gotweb.c
@@ -168,14 +168,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 - 5d6609d3bd36232b88f8c87947711ca8706284b6
blob + bc8d26743466b3016093da2bab2a199948bf752a
--- gotwebd/gotwebd.h
+++ gotwebd/gotwebd.h
@@ -520,7 +520,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 *,