diff --git a/common/flatpak-oci-registry.c b/common/flatpak-oci-registry.c index c1a1b174..7badf2ab 100644 --- a/common/flatpak-oci-registry.c +++ b/common/flatpak-oci-registry.c @@ -579,9 +579,18 @@ flatpak_oci_registry_initable_init (GInitable *initable, FlatpakOciRegistry *self = FLATPAK_OCI_REGISTRY (initable); gboolean res; - if (self->tmp_dfd == -1 && - !glnx_opendirat (AT_FDCWD, "/var/tmp", TRUE, &self->tmp_dfd, error)) - return FALSE; + if (self->tmp_dfd == -1) + { + /* We don't use TMPDIR because the downloaded artifacts can be + * very big, and we want to prefer /var/tmp to /tmp. + */ + const char *tmpdir = g_getenv ("FLATPAK_DOWNLOAD_TMPDIR"); + if (tmpdir == NULL) + tmpdir = "/var/tmp"; + + if (!glnx_opendirat (AT_FDCWD, tmpdir, TRUE, &self->tmp_dfd, error)) + return FALSE; + } if (g_str_has_prefix (self->uri, "file:/")) res = flatpak_oci_registry_ensure_local (self, self->for_write, cancellable, error);