Commit 287fe3c7 authored by Jacob Vosmaer's avatar Jacob Vosmaer

Explain the TeeReader magic

parent a9e18f2a
...@@ -260,11 +260,14 @@ func handleGetArchive(env gitEnv, format string, repoPath string, w http.Respons ...@@ -260,11 +260,14 @@ func handleGetArchive(env gitEnv, format string, repoPath string, w http.Respons
archiveStdout.Close() archiveStdout.Close()
} }
// Every Read() from stdout will be synchronously written to tempFile
// before it comes out the TeeReader.
archiveReader := io.TeeReader(stdout, tempFile)
// Start writing the response // Start writing the response
setArchiveHeaders(w, format, archiveFilename) setArchiveHeaders(w, format, archiveFilename)
w.WriteHeader(200) // Don't bother with HTTP 500 from this point on, just return w.WriteHeader(200) // Don't bother with HTTP 500 from this point on, just return
if _, err := io.Copy(w, io.TeeReader(stdout, tempFile)); err != nil { if _, err := io.Copy(w, archiveReader); err != nil {
logContext("handleGetArchive read from subprocess", err) logContext("handleGetArchive read from subprocess", err)
return return
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment