mirror of
https://github.com/ZoiteChat/zoitechat.git
synced 2026-03-22 05:30:18 +00:00
fix(win): tolerate tar/PS nonzero if files extracted; add path_tree_has_entries() to verify real output
This commit is contained in:
@@ -55,6 +55,38 @@ remove_tree (const char *path)
|
|||||||
g_rmdir (path);
|
g_rmdir (path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
path_tree_has_entries (const char *path)
|
||||||
|
{
|
||||||
|
GDir *dir;
|
||||||
|
const char *name;
|
||||||
|
|
||||||
|
if (!path || !g_file_test (path, G_FILE_TEST_EXISTS))
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
if (!g_file_test (path, G_FILE_TEST_IS_DIR))
|
||||||
|
return TRUE;
|
||||||
|
|
||||||
|
dir = g_dir_open (path, 0, NULL);
|
||||||
|
if (!dir)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
while ((name = g_dir_read_name (dir)) != NULL)
|
||||||
|
{
|
||||||
|
char *child = g_build_filename (path, name, NULL);
|
||||||
|
gboolean has_entries = path_tree_has_entries (child);
|
||||||
|
g_free (child);
|
||||||
|
if (has_entries)
|
||||||
|
{
|
||||||
|
g_dir_close (dir);
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
g_dir_close (dir);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
gtk3_css_dir_parse_minor (const char *name, gint *minor)
|
gtk3_css_dir_parse_minor (const char *name, gint *minor)
|
||||||
{
|
{
|
||||||
@@ -945,19 +977,31 @@ extract_archive (const char *source, GError **error)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!extracted || (status != 0 && !path_tree_has_entries (tmp)))
|
||||||
|
{
|
||||||
g_free (tar_program);
|
g_free (tar_program);
|
||||||
g_free (system_tar);
|
g_free (system_tar);
|
||||||
g_free (system_root);
|
g_free (system_root);
|
||||||
g_free (stdout_text);
|
g_free (stdout_text);
|
||||||
g_free (stderr_text);
|
g_free (stderr_text);
|
||||||
if (!extracted || status != 0)
|
|
||||||
{
|
|
||||||
remove_tree (tmp);
|
remove_tree (tmp);
|
||||||
g_free (tmp);
|
g_free (tmp);
|
||||||
g_set_error_literal (error, G_FILE_ERROR, G_FILE_ERROR_FAILED, "Failed to extract theme archive.");
|
g_set_error_literal (error, G_FILE_ERROR, G_FILE_ERROR_FAILED, "Failed to extract theme archive.");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Windows archive tools often return a non-zero exit status for Unix-style
|
||||||
|
* symlink entries that cannot be materialized without extra privileges.
|
||||||
|
* If regular theme files were extracted, continue and let theme validation
|
||||||
|
* decide whether the imported theme is usable.
|
||||||
|
*/
|
||||||
|
g_free (tar_program);
|
||||||
|
g_free (system_tar);
|
||||||
|
g_free (system_root);
|
||||||
|
g_free (stdout_text);
|
||||||
|
g_free (stderr_text);
|
||||||
|
|
||||||
return tmp;
|
return tmp;
|
||||||
#else
|
#else
|
||||||
struct archive *archive = NULL;
|
struct archive *archive = NULL;
|
||||||
|
|||||||
Reference in New Issue
Block a user