From: Colin Walters Date: Wed, 19 Jul 2017 13:19:16 +0000 (-0400) Subject: lib/commit: Fix EBADF with GENERATE_SIZES option for commit X-Git-Tag: archive/raspbian/2017.12-1+rpi1~1^2^2^2^2^2~1 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=54fd4155966b67249bf19ce6a25f2991890f232d;p=ostree.git lib/commit: Fix EBADF with GENERATE_SIZES option for commit Regression from previous tmpfile refactoring; unfortunately the `OSTREE_REPO_COMMIT_MODIFIER_FLAGS_GENERATE_SIZES` option only has coverage via gjs currently. Might expose it via the cmdline in a later option, but in the big picture the idea was that this data is better kept in static deltas. Bug: https://github.com/ostreedev/ostree/issues/1014 Forwarded: https://github.com/ostreedev/ostree/pull/1016 Gbp-Pq: Name lib-commit-Fix-EBADF-with-GENERATE_SIZES-option-for-commi.patch --- diff --git a/src/libostree/ostree-repo-commit.c b/src/libostree/ostree-repo-commit.c index baeef3f9..332f22a8 100644 --- a/src/libostree/ostree-repo-commit.c +++ b/src/libostree/ostree-repo-commit.c @@ -733,6 +733,17 @@ write_content_object (OstreeRepo *self, } else { + /* Update size metadata if configured */ + if (indexable && object_file_type == G_FILE_TYPE_REGULAR) + { + struct stat stbuf; + + if (!glnx_fstat (tmpf.fd, &stbuf, error)) + return FALSE; + + repo_store_size_entry (self, actual_checksum, unpacked_size, stbuf.st_size); + } + /* This path is for regular files */ if (!commit_loose_regfile_object (self, actual_checksum, &tmpf, uid, gid, mode, @@ -742,17 +753,6 @@ write_content_object (OstreeRepo *self, ostree_object_type_to_string (OSTREE_OBJECT_TYPE_FILE)); } - /* Update size metadata if configured */ - if (indexable && object_file_type == G_FILE_TYPE_REGULAR) - { - struct stat stbuf; - - if (!glnx_fstat (tmpf.fd, &stbuf, error)) - return FALSE; - - repo_store_size_entry (self, actual_checksum, unpacked_size, stbuf.st_size); - } - /* Update statistics */ g_mutex_lock (&self->txn_stats_lock); self->txn_stats.content_objects_written++;