core: Fix handling of hardlinks for tar commits
We were creating files with the wrong name. Add a test.
This commit is contained in:
parent
17cc772cf3
commit
78f435d245
|
|
@ -1730,10 +1730,10 @@ import_libarchive (OstreeRepo *self,
|
||||||
if (!file_tree_walk (root, hardlink_split_path, 0, &hardlink_parent, error))
|
if (!file_tree_walk (root, hardlink_split_path, 0, &hardlink_parent, error))
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
g_assert (parent);
|
|
||||||
|
|
||||||
hardlink_basename = hardlink_split_path->pdata[hardlink_split_path->len - 1];
|
hardlink_basename = hardlink_split_path->pdata[hardlink_split_path->len - 1];
|
||||||
|
|
||||||
|
g_assert (parent);
|
||||||
hardlink_source_checksum = g_hash_table_lookup (hardlink_parent->file_checksums, hardlink_basename);
|
hardlink_source_checksum = g_hash_table_lookup (hardlink_parent->file_checksums, hardlink_basename);
|
||||||
if (!hardlink_source_checksum)
|
if (!hardlink_source_checksum)
|
||||||
{
|
{
|
||||||
|
|
@ -1743,8 +1743,15 @@ import_libarchive (OstreeRepo *self,
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (g_hash_table_lookup (parent->subdirs, basename))
|
||||||
|
{
|
||||||
|
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
|
||||||
|
"Directory exists: %s", hardlink);
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
g_hash_table_replace (parent->file_checksums,
|
g_hash_table_replace (parent->file_checksums,
|
||||||
g_strdup (hardlink_basename),
|
g_strdup (basename),
|
||||||
g_strdup (hardlink_source_checksum));
|
g_strdup (hardlink_source_checksum));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
echo "1..1"
|
echo "1..4"
|
||||||
|
|
||||||
. libtest.sh
|
. libtest.sh
|
||||||
|
|
||||||
|
|
@ -39,5 +39,36 @@ echo not > subdir/2/notempty
|
||||||
|
|
||||||
tar -c -z -f ../foo.tar.gz .
|
tar -c -z -f ../foo.tar.gz .
|
||||||
cd ..
|
cd ..
|
||||||
$OSTREE commit -s "from tar" -b test2 --tar foo.tar.gz
|
$OSTREE commit -s "from tar" -b test-tar --tar foo.tar.gz
|
||||||
echo "ok tar commit"
|
echo "ok tar commit"
|
||||||
|
|
||||||
|
cd ${test_tmpdir}
|
||||||
|
$OSTREE checkout test-tar test-tar-checkout
|
||||||
|
cd test-tar-checkout
|
||||||
|
assert_file_has_content hi hi
|
||||||
|
assert_file_has_content hello hi
|
||||||
|
assert_file_has_content subdir/more contents
|
||||||
|
assert_has_file subdir/1/empty
|
||||||
|
assert_has_file subdir/2/empty
|
||||||
|
cd ${test_tmpdir}
|
||||||
|
rm -rf test-tar-checkout
|
||||||
|
echo "ok tar contents"
|
||||||
|
|
||||||
|
cd ${test_tmpdir}
|
||||||
|
mkdir hardlinktest
|
||||||
|
cd hardlinktest
|
||||||
|
echo other > otherfile
|
||||||
|
echo foo1 > foo
|
||||||
|
ln foo bar
|
||||||
|
tar czf ${test_tmpdir}/hardlinktest.tar.gz .
|
||||||
|
cd ${test_tmpdir}
|
||||||
|
$OSTREE commit -s 'hardlinks' -b test-hardlinks --tar hardlinktest.tar.gz
|
||||||
|
rm -rf hardlinktest
|
||||||
|
echo "ok hardlink commit"
|
||||||
|
|
||||||
|
cd ${test_tmpdir}
|
||||||
|
$OSTREE checkout test-hardlinks test-hardlinks-checkout
|
||||||
|
cd test-hardlinks-checkout
|
||||||
|
assert_file_has_content foo foo1
|
||||||
|
assert_file_has_content bar foo1
|
||||||
|
echo "ok hardlink contents"
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue