forked from Mirrors/flatpak-builder
Create and use flatpak_file_get_path_cached
This is simpler that the one in libgs, as well as lockless. Also, it removes one more use of libgs.tingping/wmclass
parent
9c907c992d
commit
65f1cf993d
|
@ -241,7 +241,7 @@ build_bundle (OstreeRepo *repo, GFile *file,
|
|||
g_variant_builder_add (¶m_builder, "{sv}", "bsdiff-enabled", g_variant_new_boolean (FALSE));
|
||||
g_variant_builder_add (¶m_builder, "{sv}", "inline-parts", g_variant_new_boolean (TRUE));
|
||||
g_variant_builder_add (¶m_builder, "{sv}", "include-detached", g_variant_new_boolean (TRUE));
|
||||
g_variant_builder_add (¶m_builder, "{sv}", "filename", g_variant_new_bytestring (gs_file_get_path_cached (file)));
|
||||
g_variant_builder_add (¶m_builder, "{sv}", "filename", g_variant_new_bytestring (flatpak_file_get_path_cached (file)));
|
||||
|
||||
if (!ostree_repo_static_delta_generate (repo,
|
||||
OSTREE_STATIC_DELTA_GENERATE_OPT_LOWLATENCY,
|
||||
|
@ -783,7 +783,7 @@ build_oci (OstreeRepo *repo, GFile *file,
|
|||
if (archive_write_add_filter_none (a) != ARCHIVE_OK)
|
||||
return propagate_libarchive_error (error, a);
|
||||
|
||||
if (archive_write_open_filename (a, gs_file_get_path_cached (file)) != ARCHIVE_OK)
|
||||
if (archive_write_open_filename (a, flatpak_file_get_path_cached (file)) != ARCHIVE_OK)
|
||||
return propagate_libarchive_error (error, a);
|
||||
|
||||
opts.timestamp_secs = ostree_commit_get_timestamp (commit_data);
|
||||
|
|
|
@ -173,8 +173,8 @@ copy_exports (GFile *source,
|
|||
return FALSE;
|
||||
|
||||
/* The fds are closed by this call */
|
||||
if (!export_dir (AT_FDCWD, gs_file_get_path_cached (source), source_prefix,
|
||||
AT_FDCWD, gs_file_get_path_cached (destination),
|
||||
if (!export_dir (AT_FDCWD, flatpak_file_get_path_cached (source), source_prefix,
|
||||
AT_FDCWD, flatpak_file_get_path_cached (destination),
|
||||
required_prefix, cancellable, error))
|
||||
return FALSE;
|
||||
|
||||
|
|
|
@ -168,8 +168,8 @@ flatpak_builtin_build (int argc, char **argv, GCancellable *cancellable, GError
|
|||
}
|
||||
|
||||
add_args (argv_array,
|
||||
custom_usr ? "--bind" : "--ro-bind", gs_file_get_path_cached (runtime_files), "/usr",
|
||||
"--bind", gs_file_get_path_cached (app_files), "/app",
|
||||
custom_usr ? "--bind" : "--ro-bind", flatpak_file_get_path_cached (runtime_files), "/usr",
|
||||
"--bind", flatpak_file_get_path_cached (app_files), "/app",
|
||||
NULL);
|
||||
|
||||
if (!flatpak_run_setup_base_argv (argv_array, NULL, runtime_files, NULL, runtime_ref_parts[2],
|
||||
|
@ -179,7 +179,7 @@ flatpak_builtin_build (int argc, char **argv, GCancellable *cancellable, GError
|
|||
|
||||
/* After setup_base to avoid conflicts with /var symlinks */
|
||||
add_args (argv_array,
|
||||
"--bind", gs_file_get_path_cached (var), "/var",
|
||||
"--bind", flatpak_file_get_path_cached (var), "/var",
|
||||
NULL);
|
||||
|
||||
app_context = flatpak_context_new ();
|
||||
|
|
|
@ -308,7 +308,7 @@ builder_cache_checkout (BuilderCache *self, const char *commit, GError **error)
|
|||
/* There is a bug in ostree (https://github.com/ostreedev/ostree/issues/326) that
|
||||
causes it to not reset mtime to 1 in this case (mismatching modes). So
|
||||
we do that manually */
|
||||
if (!flatpak_zero_mtime (AT_FDCWD, gs_file_get_path_cached (self->app_dir),
|
||||
if (!flatpak_zero_mtime (AT_FDCWD, flatpak_file_get_path_cached (self->app_dir),
|
||||
NULL, error))
|
||||
return FALSE;
|
||||
|
||||
|
@ -421,7 +421,7 @@ builder_cache_commit (BuilderCache *self,
|
|||
|
||||
/* We set all mtimes to 1 during a commit, to simulate what would happen when
|
||||
running via flatpak deploy (and also if we checked out from the cache). */
|
||||
if (!flatpak_zero_mtime (AT_FDCWD, gs_file_get_path_cached (self->app_dir),
|
||||
if (!flatpak_zero_mtime (AT_FDCWD, flatpak_file_get_path_cached (self->app_dir),
|
||||
NULL, NULL))
|
||||
return FALSE;
|
||||
|
||||
|
|
|
@ -1340,8 +1340,8 @@ foreach_file (BuilderManifest *self,
|
|||
GError **error)
|
||||
{
|
||||
return foreach_file_helper (self, func, AT_FDCWD,
|
||||
gs_file_get_path_cached (root),
|
||||
gs_file_get_path_cached (root),
|
||||
flatpak_file_get_path_cached (root),
|
||||
flatpak_file_get_path_cached (root),
|
||||
"",
|
||||
found, 0,
|
||||
error);
|
||||
|
|
|
@ -1441,7 +1441,7 @@ builder_module_build (BuilderModule *self,
|
|||
if (!self->no_python_timestamp_fix)
|
||||
{
|
||||
if (!fixup_python_timestamp (AT_FDCWD,
|
||||
gs_file_get_path_cached (app_dir), "/",
|
||||
flatpak_file_get_path_cached (app_dir), "/",
|
||||
NULL,
|
||||
error))
|
||||
return FALSE;
|
||||
|
|
|
@ -325,7 +325,7 @@ flatpak_dir_set_property (GObject *object,
|
|||
{
|
||||
case PROP_PATH:
|
||||
/* Canonicalize */
|
||||
self->basedir = g_file_new_for_path (gs_file_get_path_cached (g_value_get_object (value)));
|
||||
self->basedir = g_file_new_for_path (flatpak_file_get_path_cached (g_value_get_object (value)));
|
||||
break;
|
||||
|
||||
case PROP_USER:
|
||||
|
@ -1167,7 +1167,7 @@ flatpak_dir_update_appstream (FlatpakDir *self,
|
|||
else
|
||||
{
|
||||
if (!flatpak_system_helper_call_deploy_appstream_sync (system_helper,
|
||||
gs_file_get_path_cached (ostree_repo_get_path (child_repo)),
|
||||
flatpak_file_get_path_cached (ostree_repo_get_path (child_repo)),
|
||||
remote,
|
||||
arch,
|
||||
cancellable,
|
||||
|
@ -2375,7 +2375,7 @@ flatpak_rewrite_export_dir (const char *app,
|
|||
|
||||
/* The fds are closed by this call */
|
||||
if (!rewrite_export_dir (app, branch, arch, metadata,
|
||||
AT_FDCWD, gs_file_get_path_cached (source),
|
||||
AT_FDCWD, flatpak_file_get_path_cached (source),
|
||||
cancellable, error))
|
||||
goto out;
|
||||
|
||||
|
@ -2494,8 +2494,8 @@ flatpak_export_dir (GFile *source,
|
|||
goto out;
|
||||
|
||||
/* The fds are closed by this call */
|
||||
if (!export_dir (AT_FDCWD, gs_file_get_path_cached (source), symlink_prefix, "",
|
||||
AT_FDCWD, gs_file_get_path_cached (destination),
|
||||
if (!export_dir (AT_FDCWD, flatpak_file_get_path_cached (source), symlink_prefix, "",
|
||||
AT_FDCWD, flatpak_file_get_path_cached (destination),
|
||||
cancellable, error))
|
||||
goto out;
|
||||
|
||||
|
@ -2979,7 +2979,7 @@ flatpak_dir_create_system_child_repo (FlatpakDir *self,
|
|||
return NULL;
|
||||
|
||||
if (!flatpak_allocate_tmpdir (AT_FDCWD,
|
||||
gs_file_get_path_cached (cache_dir),
|
||||
flatpak_file_get_path_cached (cache_dir),
|
||||
"repo-", &tmpdir_name,
|
||||
NULL,
|
||||
file_lock,
|
||||
|
@ -3008,7 +3008,7 @@ flatpak_dir_create_system_child_repo (FlatpakDir *self,
|
|||
/* Ensure the config is updated */
|
||||
config = ostree_repo_copy_config (new_repo);
|
||||
g_key_file_set_string (config, "core", "parent",
|
||||
gs_file_get_path_cached (ostree_repo_get_path (self->repo)));
|
||||
flatpak_file_get_path_cached (ostree_repo_get_path (self->repo)));
|
||||
|
||||
if (!ostree_repo_write_config (new_repo, config, error))
|
||||
return NULL;
|
||||
|
@ -3158,7 +3158,7 @@ flatpak_dir_install_bundle (FlatpakDir *self,
|
|||
gpg_data_v = g_variant_ref_sink (g_variant_new_from_data (G_VARIANT_TYPE ("ay"), "", 0, TRUE, NULL, NULL));
|
||||
|
||||
if (!flatpak_system_helper_call_install_bundle_sync (system_helper,
|
||||
gs_file_get_path_cached (file),
|
||||
flatpak_file_get_path_cached (file),
|
||||
0, gpg_data_v,
|
||||
&ref,
|
||||
cancellable,
|
||||
|
@ -3648,7 +3648,7 @@ dir_is_locked (GFile *dir)
|
|||
|
||||
reffile = g_file_resolve_relative_path (dir, "files/.ref");
|
||||
|
||||
ref_fd = open (gs_file_get_path_cached (reffile), O_RDWR | O_CLOEXEC);
|
||||
ref_fd = open (flatpak_file_get_path_cached (reffile), O_RDWR | O_CLOEXEC);
|
||||
if (ref_fd != -1)
|
||||
{
|
||||
lock.l_type = F_WRLCK;
|
||||
|
|
|
@ -1966,7 +1966,7 @@ flatpak_run_add_environment_args (GPtrArray *argv_array,
|
|||
/* Do this after setting up everything in the home dir, so its not overwritten */
|
||||
if (app_id_dir)
|
||||
add_args (argv_array,
|
||||
"--bind", gs_file_get_path_cached (app_id_dir), gs_file_get_path_cached (app_id_dir),
|
||||
"--bind", flatpak_file_get_path_cached (app_id_dir), flatpak_file_get_path_cached (app_id_dir),
|
||||
NULL);
|
||||
|
||||
if (home_access && app_id_dir != NULL)
|
||||
|
@ -1974,7 +1974,7 @@ flatpak_run_add_environment_args (GPtrArray *argv_array,
|
|||
g_autofree char *src_path = g_build_filename (g_get_user_config_dir (),
|
||||
"user-dirs.dirs",
|
||||
NULL);
|
||||
g_autofree char *path = g_build_filename (gs_file_get_path_cached (app_id_dir),
|
||||
g_autofree char *path = g_build_filename (flatpak_file_get_path_cached (app_id_dir),
|
||||
"config/user-dirs.dirs", NULL);
|
||||
if (g_file_test (src_path, G_FILE_TEST_EXISTS))
|
||||
add_args (argv_array,
|
||||
|
@ -2000,7 +2000,7 @@ flatpak_run_add_environment_args (GPtrArray *argv_array,
|
|||
g_autofree char *tmp_fd_str = g_strdup_printf ("%d", tmp_fd);
|
||||
if (fd_array)
|
||||
g_array_append_val (fd_array, tmp_fd);
|
||||
path = g_build_filename (gs_file_get_path_cached (app_id_dir),
|
||||
path = g_build_filename (flatpak_file_get_path_cached (app_id_dir),
|
||||
"config/user-dirs.dirs", NULL);
|
||||
|
||||
add_args (argv_array, "--file", tmp_fd_str, path, NULL);
|
||||
|
@ -2163,9 +2163,9 @@ flatpak_run_apply_env_appid (char **envp,
|
|||
app_dir_data = g_file_get_child (app_dir, "data");
|
||||
app_dir_config = g_file_get_child (app_dir, "config");
|
||||
app_dir_cache = g_file_get_child (app_dir, "cache");
|
||||
envp = g_environ_setenv (envp, "XDG_DATA_HOME", gs_file_get_path_cached (app_dir_data), TRUE);
|
||||
envp = g_environ_setenv (envp, "XDG_CONFIG_HOME", gs_file_get_path_cached (app_dir_config), TRUE);
|
||||
envp = g_environ_setenv (envp, "XDG_CACHE_HOME", gs_file_get_path_cached (app_dir_cache), TRUE);
|
||||
envp = g_environ_setenv (envp, "XDG_DATA_HOME", flatpak_file_get_path_cached (app_dir_data), TRUE);
|
||||
envp = g_environ_setenv (envp, "XDG_CONFIG_HOME", flatpak_file_get_path_cached (app_dir_config), TRUE);
|
||||
envp = g_environ_setenv (envp, "XDG_CACHE_HOME", flatpak_file_get_path_cached (app_dir_cache), TRUE);
|
||||
|
||||
return envp;
|
||||
}
|
||||
|
@ -2354,13 +2354,13 @@ add_font_path_args (GPtrArray *argv_array)
|
|||
if (g_file_query_exists (user_font1, NULL))
|
||||
{
|
||||
add_args (argv_array,
|
||||
"--bind", gs_file_get_path_cached (user_font1), "/run/host/user-fonts",
|
||||
"--bind", flatpak_file_get_path_cached (user_font1), "/run/host/user-fonts",
|
||||
NULL);
|
||||
}
|
||||
else if (g_file_query_exists (user_font2, NULL))
|
||||
{
|
||||
add_args (argv_array,
|
||||
"--bind", gs_file_get_path_cached (user_font2), "/run/host/user-fonts",
|
||||
"--bind", flatpak_file_get_path_cached (user_font2), "/run/host/user-fonts",
|
||||
NULL);
|
||||
}
|
||||
}
|
||||
|
@ -2925,7 +2925,7 @@ flatpak_run_setup_base_argv (GPtrArray *argv_array,
|
|||
char path_buffer[PATH_MAX + 1];
|
||||
ssize_t symlink_size;
|
||||
|
||||
glnx_dirfd_iterator_init_at (AT_FDCWD, gs_file_get_path_cached (etc), FALSE, &dfd_iter, NULL);
|
||||
glnx_dirfd_iterator_init_at (AT_FDCWD, flatpak_file_get_path_cached (etc), FALSE, &dfd_iter, NULL);
|
||||
|
||||
while (TRUE)
|
||||
{
|
||||
|
@ -2942,7 +2942,7 @@ flatpak_run_setup_base_argv (GPtrArray *argv_array,
|
|||
strcmp (dent->d_name, "localtime") == 0)
|
||||
continue;
|
||||
|
||||
src = g_build_filename (gs_file_get_path_cached (etc), dent->d_name, NULL);
|
||||
src = g_build_filename (flatpak_file_get_path_cached (etc), dent->d_name, NULL);
|
||||
dest = g_build_filename ("/etc", dent->d_name, NULL);
|
||||
if (dent->d_type == DT_LNK)
|
||||
{
|
||||
|
@ -2970,9 +2970,9 @@ flatpak_run_setup_base_argv (GPtrArray *argv_array,
|
|||
|
||||
add_args (argv_array,
|
||||
/* These are nice to have as a fixed path */
|
||||
"--bind", gs_file_get_path_cached (app_cache_dir), "/var/cache",
|
||||
"--bind", gs_file_get_path_cached (app_data_dir), "/var/data",
|
||||
"--bind", gs_file_get_path_cached (app_config_dir), "/var/config",
|
||||
"--bind", flatpak_file_get_path_cached (app_cache_dir), "/var/cache",
|
||||
"--bind", flatpak_file_get_path_cached (app_data_dir), "/var/data",
|
||||
"--bind", flatpak_file_get_path_cached (app_config_dir), "/var/config",
|
||||
NULL);
|
||||
}
|
||||
|
||||
|
@ -3169,9 +3169,9 @@ flatpak_run_app (const char *app_ref,
|
|||
envp = flatpak_run_apply_env_appid (envp, app_id_dir);
|
||||
|
||||
add_args (argv_array,
|
||||
"--ro-bind", gs_file_get_path_cached (runtime_files), "/usr",
|
||||
"--ro-bind", flatpak_file_get_path_cached (runtime_files), "/usr",
|
||||
"--lock-file", "/usr/.ref",
|
||||
"--ro-bind", gs_file_get_path_cached (app_files), "/app",
|
||||
"--ro-bind", flatpak_file_get_path_cached (app_files), "/app",
|
||||
"--lock-file", "/app/.ref",
|
||||
NULL);
|
||||
|
||||
|
|
|
@ -812,9 +812,9 @@ flatpak_overlay_symlink_tree (GFile *source,
|
|||
goto out;
|
||||
|
||||
/* The fds are closed by this call */
|
||||
if (!overlay_symlink_tree_dir (AT_FDCWD, gs_file_get_path_cached (source),
|
||||
if (!overlay_symlink_tree_dir (AT_FDCWD, flatpak_file_get_path_cached (source),
|
||||
symlink_prefix,
|
||||
AT_FDCWD, gs_file_get_path_cached (destination),
|
||||
AT_FDCWD, flatpak_file_get_path_cached (destination),
|
||||
cancellable, error))
|
||||
goto out;
|
||||
|
||||
|
@ -878,7 +878,7 @@ flatpak_remove_dangling_symlinks (GFile *dir,
|
|||
gboolean ret = FALSE;
|
||||
|
||||
/* The fd is closed by this call */
|
||||
if (!remove_dangling_symlinks (AT_FDCWD, gs_file_get_path_cached (dir),
|
||||
if (!remove_dangling_symlinks (AT_FDCWD, flatpak_file_get_path_cached (dir),
|
||||
cancellable, error))
|
||||
goto out;
|
||||
|
||||
|
@ -1393,6 +1393,35 @@ flatpak_spawnv (GFile *dir,
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
const char *
|
||||
flatpak_file_get_path_cached (GFile *file)
|
||||
{
|
||||
const char *path;
|
||||
static GQuark _file_path_quark = 0;
|
||||
|
||||
if (G_UNLIKELY (_file_path_quark) == 0)
|
||||
_file_path_quark = g_quark_from_static_string ("flatpak-file-path");
|
||||
|
||||
do
|
||||
{
|
||||
path = g_object_get_qdata ((GObject*)file, _file_path_quark);
|
||||
if (path == NULL)
|
||||
{
|
||||
g_autofree char *new_path = NULL;
|
||||
new_path = g_file_get_path (file);
|
||||
if (new_path == NULL)
|
||||
return NULL;
|
||||
|
||||
if (g_object_replace_qdata ((GObject*)file, _file_path_quark,
|
||||
NULL, new_path, g_free, NULL))
|
||||
path = g_steal_pointer (&new_path);
|
||||
}
|
||||
}
|
||||
while (path == NULL);
|
||||
|
||||
return path;
|
||||
}
|
||||
|
||||
gboolean
|
||||
flatpak_cp_a (GFile *src,
|
||||
GFile *dest,
|
||||
|
@ -1424,7 +1453,7 @@ flatpak_cp_a (GFile *src,
|
|||
goto out;
|
||||
|
||||
do
|
||||
r = mkdir (gs_file_get_path_cached (dest), 0755);
|
||||
r = mkdir (flatpak_file_get_path_cached (dest), 0755);
|
||||
while (G_UNLIKELY (r == -1 && errno == EINTR));
|
||||
if (r == -1 &&
|
||||
(!merge || errno != EEXIST))
|
||||
|
@ -1485,7 +1514,7 @@ flatpak_cp_a (GFile *src,
|
|||
}
|
||||
else
|
||||
{
|
||||
(void) unlink (gs_file_get_path_cached (dest_child));
|
||||
(void) unlink (flatpak_file_get_path_cached (dest_child));
|
||||
GFileCopyFlags copyflags = G_FILE_COPY_OVERWRITE | G_FILE_COPY_NOFOLLOW_SYMLINKS;
|
||||
if (!no_chown)
|
||||
copyflags |= G_FILE_COPY_ALL_METADATA;
|
||||
|
@ -1581,7 +1610,7 @@ flatpak_mkdir_p (GFile *dir,
|
|||
GError **error)
|
||||
{
|
||||
return glnx_shutil_mkdir_p_at (AT_FDCWD,
|
||||
gs_file_get_path_cached (dir),
|
||||
flatpak_file_get_path_cached (dir),
|
||||
0777,
|
||||
cancellable,
|
||||
error);
|
||||
|
@ -1593,7 +1622,7 @@ flatpak_rm_rf (GFile *dir,
|
|||
GError **error)
|
||||
{
|
||||
return glnx_shutil_rm_rf_at (AT_FDCWD,
|
||||
gs_file_get_path_cached (dir),
|
||||
flatpak_file_get_path_cached (dir),
|
||||
cancellable, error);
|
||||
}
|
||||
|
||||
|
@ -2914,7 +2943,7 @@ flatpak_bundle_load (GFile *file,
|
|||
guint8 endianness_char;
|
||||
gboolean byte_swap = FALSE;
|
||||
|
||||
GMappedFile *mfile = g_mapped_file_new (gs_file_get_path_cached (file), FALSE, error);
|
||||
GMappedFile *mfile = g_mapped_file_new (flatpak_file_get_path_cached (file), FALSE, error);
|
||||
|
||||
if (mfile == NULL)
|
||||
return NULL;
|
||||
|
|
|
@ -256,6 +256,8 @@ gboolean flatpak_spawnv (GFile *dir,
|
|||
GError **error,
|
||||
const gchar * const *argv);
|
||||
|
||||
const char *flatpak_file_get_path_cached (GFile *file);
|
||||
|
||||
typedef enum {
|
||||
FLATPAK_CP_FLAGS_NONE = 0,
|
||||
FLATPAK_CP_FLAGS_MERGE = 1<<0,
|
||||
|
|
Loading…
Reference in New Issue