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
This commit is contained in:
1 parent
7f6af94c5a
commit
2e3889a4eb
5 files changed
+86
-107
No files matched your search
@@ -25,14 +25,23 @@
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
/* FIXME - delete this and replace by having fetchers simply
|
||||
* return O_TMPFILE fds, not file paths.
|
||||
*/
|
||||
static inline char *
|
||||
ostree_fetcher_generate_url_tmpname (const char *url)
|
||||
static inline gboolean
|
||||
_ostree_fetcher_tmpf_from_flags (OstreeFetcherRequestFlags flags,
|
||||
int dfd,
|
||||
GLnxTmpfile *tmpf,
|
||||
GError **error)
|
||||
{
|
||||
return g_compute_checksum_for_string (G_CHECKSUM_SHA256,
|
||||
url, strlen (url));
|
||||
if ((flags & OSTREE_FETCHER_REQUEST_LINKABLE) > 0)
|
||||
{
|
||||
if (!glnx_open_tmpfile_linkable_at (dfd, ".", O_RDWR | O_CLOEXEC, tmpf, error))
|
||||
return FALSE;
|
||||
}
|
||||
else if (!glnx_open_anonymous_tmpfile (O_RDWR | O_CLOEXEC, tmpf, error))
|
||||
return FALSE;
|
||||
|
||||
if (!glnx_fchmod (tmpf->fd, 0644, error))
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gboolean _ostree_fetcher_mirrored_request_to_membuf (OstreeFetcher *fetcher,
|
||||
|
||||
Reference in new issue
Block a user