mirror of
https://github.com/ostreedev/ostree.git
synced 2025-03-19 22:50:35 +03:00
commit: Reject non-regular/non-symlinks earlier with better error message
Also avoid _NOT_SUPPORTED as that triggers the --help behavior from the commandline; just use _FAILED. https://bugzilla.gnome.org/show_bug.cgi?id=722410
This commit is contained in:
parent
b2d0ba7ac1
commit
5034bf3a9d
@ -385,7 +385,7 @@ write_object (OstreeRepo *self,
|
||||
|
||||
if (!(temp_file_is_regular || is_symlink))
|
||||
{
|
||||
g_set_error (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
|
||||
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
|
||||
"Unsupported file type %u", g_file_info_get_file_type (file_info));
|
||||
goto out;
|
||||
}
|
||||
@ -1785,9 +1785,25 @@ write_directory_to_mtree_internal (OstreeRepo *self,
|
||||
|
||||
if (filter_result == OSTREE_REPO_COMMIT_FILTER_ALLOW)
|
||||
{
|
||||
GFileType file_type;
|
||||
|
||||
child = g_file_get_child (dir, name);
|
||||
|
||||
if (g_file_info_get_file_type (child_info) == G_FILE_TYPE_DIRECTORY)
|
||||
file_type = g_file_info_get_file_type (child_info);
|
||||
switch (file_type)
|
||||
{
|
||||
case G_FILE_TYPE_DIRECTORY:
|
||||
case G_FILE_TYPE_SYMBOLIC_LINK:
|
||||
case G_FILE_TYPE_REGULAR:
|
||||
break;
|
||||
default:
|
||||
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
|
||||
"Unsupported file type: '%s'",
|
||||
gs_file_get_path_cached (child));
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (file_type == G_FILE_TYPE_DIRECTORY)
|
||||
{
|
||||
if (!ostree_mutable_tree_ensure_dir (mtree, name, &child_mtree, error))
|
||||
goto out;
|
||||
|
@ -317,3 +317,14 @@ stat '--format=%Y' test2-checkout/baz/cow > cow-mtime
|
||||
assert_file_has_content cow-mtime 0
|
||||
echo "ok content mtime"
|
||||
|
||||
cd ${test_tmpdir}
|
||||
rm -rf test2-checkout
|
||||
mkdir -p test2-checkout
|
||||
cd test2-checkout
|
||||
mkfifo afifo
|
||||
if $OSTREE commit -b test2 -s "Attempt to commit a FIFO" 2>../errmsg; then
|
||||
assert_not_reached "Committing a FIFO unexpetedly succeeded!"
|
||||
assert_file_has_content ../errmsg "Unsupported file type"
|
||||
fi
|
||||
echo "ok commit of fifo was rejected"
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user