Hello,
On Mon, Feb 16, 2026 at 08:37:27PM +0100, Pavel Cahyna wrote:
> Another issue that I am aware of is that I am not sure whether to call
> repair_delayed_set_stat and/or delay_set_stat on the newly created
> directories like extract_dir() does (the whole delay_set code is abit
> mysterious to me).
Regarding this question, I found that the previous patch causes errors
when one uses --one-top-level and the tarball contains ".". The
following additional patch that avoids calling delay_set_stat for the
intermediate directories that we create as the result of --one-top-level
fixes it (of course it should be done in a nicer way, this is merely a
proof of concept):
--- a/src/extract.c
+++ b/src/extract.c
@@ -216,6 +216,8 @@ static Hash_table *delayed_link_table;
static struct delayed_link *delayed_link_head;
static struct delayed_link **delayed_link_tail = &delayed_link_head;
+static bool one_top_level_prepare = false;
+
struct string_list
{
struct string_list *next;
@@ -815,6 +817,7 @@ make_directories (char *file_name, bool *interdir_made)
/* Create a struct delayed_set_stat even if
mode == desired_mode, because
repair_delayed_set_stat may need to update the struct. */
+ if (! one_top_level_prepare)
delay_set_stat (file_name,
NULL, mode & ~ current_umask, MODE_RWX,
desired_mode, AT_SYMLINK_NOFOLLOW);
@@ -1991,7 +1994,9 @@ extract_archive (void)
if (fun)
{
/* create one_top_level dir if it does not exist */
+ one_top_level_prepare = true;
chdir_do (chdir_current, one_top_level_option);
+ one_top_level_prepare = false;
if (fun (current_stat_info.file_name, typeflag))
return;
}
What do you think about the approach outlined in the previous message,
is it otherwise sound?
Regards, Pavel