Skip to content

Commit

Permalink
lib/commit: don't query devino cache for modified files
Browse files Browse the repository at this point in the history
We can't use the cache if the file we want to commit has been modified
by the client through the modifier. In fact, the issue in #1165 was
already solved by the previous commit, in which we stopped calling
devino_cache_lookup() prematurely, because the dup'ed file_info here
doesn't even have a device/inode attribute, so we would always get a
cache miss. Though this is the more correct thing to do in general.

Closes: #1165
  • Loading branch information
jlebon committed Sep 13, 2017
1 parent fc56b99 commit 21776b6
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/libostree/ostree-repo-commit.c
Original file line number Diff line number Diff line change
Expand Up @@ -2557,6 +2557,7 @@ write_directory_content_to_mtree_internal (OstreeRepo *self,
g_autoptr(GFileInfo) modified_info = NULL;
OstreeRepoCommitFilterResult filter_result =
_ostree_repo_commit_modifier_apply (self, modifier, child_relpath, child_info, &modified_info);
const gboolean child_info_was_modified = (child_info == modified_info);

if (filter_result != OSTREE_REPO_COMMIT_FILTER_ALLOW)
{
Expand Down Expand Up @@ -2618,16 +2619,20 @@ write_directory_content_to_mtree_internal (OstreeRepo *self,
else
{
guint64 file_obj_length;
const char *loose_checksum;
g_autoptr(GInputStream) file_input = NULL;
g_autoptr(GVariant) xattrs = NULL;
g_autoptr(GInputStream) file_object_input = NULL;
g_autofree guchar *child_file_csum = NULL;
g_autofree char *tmp_checksum = NULL;

loose_checksum = devino_cache_lookup (self, modifier,
g_file_info_get_attribute_uint32 (child_info, "unix::device"),
g_file_info_get_attribute_uint64 (child_info, "unix::inode"));
/* only check the devino cache if the file info was not modified */
const char *loose_checksum = NULL;
if (!child_info_was_modified)
{
guint32 dev = g_file_info_get_attribute_uint32 (child_info, "unix::device");
guint64 inode = g_file_info_get_attribute_uint64 (child_info, "unix::inode");
loose_checksum = devino_cache_lookup (self, modifier, dev, inode);
}

if (loose_checksum)
{
Expand Down

0 comments on commit 21776b6

Please sign in to comment.