lib/pull: Change fetcher to return O_TMPFILE
authorColin Walters <walters@verbum.org>
Tue, 3 Oct 2017 01:36:10 +0000 (21:36 -0400)
committerAtomic Bot <atomic-devel@projectatomic.io>
Thu, 5 Oct 2017 14:58:20 +0000 (14:58 +0000)
commit2e3889a4eb2e33b6cd0e0cc683ee9f047a756b6e
tree704d914b05ee74aa2d233fef424c663e2ac81905
parent7f6af94c5a9a1ffa411636225baf5cb51de08144
lib/pull: Change fetcher to return O_TMPFILE

A lot of the libostree code is honestly too complex for its
own good (this is mostly my fault).  The way we do HTTP writes
is still one of those.  The way the fetcher writes tempfiles,
then reads them back in is definitely one of those.

Now that we've dropped the "partial object" bits in:
https://github.com/ostreedev/ostree/pull/1176 i.e. commit
https://github.com/ostreedev/ostree/commit/0488b4870e80ef575d8b0edf6f2a9e5ad54bf4df
we can simplify things a lot more by having the fetcher
return an `O_TMPFILE` rather than a filename.

For trusted archive mirroring, we need to enable linking
in the tmpfiles directly.

Otherwise for at least content objects they're compressed, so we couldn't link
them in. For metadata, we need to do similar logic to what we have around
`mmap()` to only grab a tmpfile if the size is large enough.

Closes: #1252
Approved by: jlebon
src/libostree/ostree-fetcher-curl.c
src/libostree/ostree-fetcher-soup.c
src/libostree/ostree-fetcher-util.h
src/libostree/ostree-fetcher.h
src/libostree/ostree-repo-pull.c