mirror of
https://github.com/ostreedev/ostree.git
synced 2025-03-19 22:50:35 +03:00
core: drop dead/unused code
The daemon is a nice idea but needs a lot more thought. Let's just delete the unused code for now and come back to it later.
This commit is contained in:
parent
311493338e
commit
664e9b404d
@ -36,161 +36,9 @@ static GDBusNodeInfo *introspection_data = NULL;
|
||||
static const gchar introspection_xml[] =
|
||||
"<node>"
|
||||
" <interface name='org.gnome.OSTree'>"
|
||||
" <method name='CancelOperation'>"
|
||||
" <arg type='u' name='id' direction='in'/>"
|
||||
" </method>"
|
||||
" <method name='AddBootRoot'>"
|
||||
" <arg type='s' name='revision' direction='in'/>"
|
||||
" <arg type='u' name='op_id' direction='out'/>"
|
||||
" </method>"
|
||||
" <method name='RemoveBootRoot'>"
|
||||
" <arg type='s' name='revision' direction='in'/>"
|
||||
" <arg type='u' name='op_id' direction='out'/>"
|
||||
" </method>"
|
||||
" <method name='SetBootRoot'>"
|
||||
" <arg type='s' name='revision' direction='in'/>"
|
||||
" <arg type='u' name='op_id' direction='out'/>"
|
||||
" </method>"
|
||||
" <method name='Overlay'>"
|
||||
" <arg type='s' name='dir' direction='in'/>"
|
||||
" <arg type='u' name='op_id' direction='out'/>"
|
||||
" </method>"
|
||||
" <method name='Diff'>"
|
||||
" <arg type='s' name='dir' direction='in'/>"
|
||||
" <arg type='h' name='handle' direction='out'/>"
|
||||
" </method>"
|
||||
" <signal name='OperationEnded'>"
|
||||
" <arg type='u' name='op_id' />"
|
||||
" <arg type='b' name='successful' />"
|
||||
" <arg type='s' name='result_str' />"
|
||||
" </signal>"
|
||||
" </interface>"
|
||||
"</node>";
|
||||
|
||||
static void
|
||||
operation_new (OstreeDaemon *self,
|
||||
const char *sender,
|
||||
guint *out_id,
|
||||
OstreeDaemonOperation **out_op)
|
||||
{
|
||||
|
||||
*out_id = ++self->op_id;
|
||||
*out_op = g_new0 (OstreeDaemonOperation, 1);
|
||||
(*out_op)->requestor_dbus_name = g_strdup (sender);
|
||||
(*out_op)->cancellable = g_cancellable_new ();
|
||||
}
|
||||
|
||||
static void
|
||||
operation_free (OstreeDaemonOperation *op)
|
||||
{
|
||||
g_free (op->requestor_dbus_name);
|
||||
g_object_unref (op->cancellable);
|
||||
g_free (op);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
op_return (OstreeDaemon *self,
|
||||
OstreeDaemonOperation *op,
|
||||
GError *error_return)
|
||||
{
|
||||
gboolean ret = FALSE;
|
||||
GVariant *args = NULL;
|
||||
|
||||
g_hash_table_remove (self->ops, GUINT_TO_POINTER (op->id));
|
||||
|
||||
if (error_return)
|
||||
args = g_variant_new ("(ubs)", op->id, FALSE, error_return->message);
|
||||
else
|
||||
args = g_variant_new ("(ubs)", op->id, TRUE, "Success");
|
||||
|
||||
g_dbus_connection_emit_signal (self->bus,
|
||||
op->requestor_dbus_name,
|
||||
OSTREE_DAEMON_PATH,
|
||||
OSTREE_DAEMON_IFACE,
|
||||
"OperationEnded",
|
||||
args,
|
||||
NULL);
|
||||
|
||||
ret = TRUE;
|
||||
operation_free (op);
|
||||
ot_clear_gvariant (&args);
|
||||
return ret;
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
OstreeDaemonOperation *op;
|
||||
GFile *dir;
|
||||
} OverlayDirThreadData;
|
||||
|
||||
typedef struct {
|
||||
OverlayDirThreadData *tdata;
|
||||
GError *error;
|
||||
} OverlayDirEmitInIdleData;
|
||||
|
||||
static gboolean
|
||||
overlay_dir_emit_in_idle (gpointer data)
|
||||
{
|
||||
OverlayDirEmitInIdleData *idledata = data;
|
||||
|
||||
op_return (idledata->tdata->op->daemon,
|
||||
idledata->tdata->op,
|
||||
idledata->error);
|
||||
|
||||
g_free (idledata);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static gpointer
|
||||
overlay_dir_thread (gpointer data)
|
||||
{
|
||||
OverlayDirThreadData *tdata = data;
|
||||
GMainContext *context = NULL;
|
||||
GFile *sysroot_f = NULL;
|
||||
OverlayDirEmitInIdleData *idledata = g_new0 (OverlayDirEmitInIdleData, 1);
|
||||
|
||||
idledata->tdata = tdata;
|
||||
|
||||
context = g_main_context_new ();
|
||||
|
||||
sysroot_f = g_file_new_for_path ("/sysroot/ostree/current");
|
||||
|
||||
g_main_context_push_thread_default (context);
|
||||
|
||||
(void)ot_gfile_merge_dirs (sysroot_f,
|
||||
tdata->dir,
|
||||
tdata->op->cancellable,
|
||||
&(idledata->error));
|
||||
g_idle_add (overlay_dir_emit_in_idle, idledata);
|
||||
|
||||
g_main_context_pop_thread_default (context);
|
||||
|
||||
g_main_context_unref (context);
|
||||
|
||||
g_clear_object (&tdata->dir);
|
||||
g_free (tdata);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
do_op_overlay (OstreeDaemon *self,
|
||||
const char *dir,
|
||||
OstreeDaemonOperation *op)
|
||||
{
|
||||
OverlayDirThreadData *tdata = g_new0 (OverlayDirThreadData, 1);
|
||||
|
||||
tdata->op = op;
|
||||
tdata->dir = g_file_new_for_path (dir);
|
||||
|
||||
#if GLIB_CHECK_VERSION(2,32,0) && !defined(OSTREE_GLIB_TARGET_MIN)
|
||||
g_thread_new ("overlay-dir-thread", overlay_dir_thread, tdata);
|
||||
#else
|
||||
g_thread_create_full (overlay_dir_thread, tdata, 0, FALSE, FALSE,
|
||||
G_THREAD_PRIORITY_NORMAL, NULL);
|
||||
#endif
|
||||
}
|
||||
|
||||
static void
|
||||
handle_method_call (GDBusConnection *connection,
|
||||
const gchar *sender,
|
||||
@ -201,23 +49,6 @@ handle_method_call (GDBusConnection *connection,
|
||||
GDBusMethodInvocation *invocation,
|
||||
gpointer user_data)
|
||||
{
|
||||
OstreeDaemon *self = user_data;
|
||||
guint32 op_id;
|
||||
OstreeDaemonOperation *op;
|
||||
|
||||
if (g_strcmp0 (method_name, "Overlay") == 0)
|
||||
{
|
||||
const gchar *dirpath;
|
||||
|
||||
g_variant_get (parameters, "(&s)", &dirpath);
|
||||
|
||||
operation_new (self, sender, &op_id, &op);
|
||||
|
||||
do_op_overlay (self, dirpath, op);
|
||||
|
||||
g_dbus_method_invocation_return_value (invocation,
|
||||
g_variant_new ("(u)", op_id));
|
||||
}
|
||||
}
|
||||
|
||||
static const GDBusInterfaceVTable interface_vtable =
|
||||
|
@ -394,90 +394,3 @@ ot_gio_checksum_stream_finish (GInputStream *in,
|
||||
return g_memdup (g_simple_async_result_get_op_res_gpointer (simple), 32);
|
||||
|
||||
}
|
||||
|
||||
gboolean
|
||||
ot_gfile_merge_dirs (GFile *destination,
|
||||
GFile *src,
|
||||
GCancellable *cancellable,
|
||||
GError **error)
|
||||
{
|
||||
gboolean ret = FALSE;
|
||||
const char *dest_path = NULL;
|
||||
const char *src_path = NULL;
|
||||
GError *temp_error = NULL;
|
||||
const char *name;
|
||||
guint32 type;
|
||||
const int move_flags = G_FILE_COPY_OVERWRITE | G_FILE_COPY_NOFOLLOW_SYMLINKS | G_FILE_COPY_ALL_METADATA;
|
||||
ot_lobj GFileInfo *src_fileinfo = NULL;
|
||||
ot_lobj GFileInfo *dest_fileinfo = NULL;
|
||||
ot_lobj GFileEnumerator *src_enum = NULL;
|
||||
ot_lobj GFile *dest_subfile = NULL;
|
||||
ot_lobj GFile *src_subfile = NULL;
|
||||
|
||||
dest_path = ot_gfile_get_path_cached (destination);
|
||||
src_path = ot_gfile_get_path_cached (src);
|
||||
|
||||
dest_fileinfo = g_file_query_info (destination, OSTREE_GIO_FAST_QUERYINFO,
|
||||
G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS,
|
||||
cancellable, &temp_error);
|
||||
if (dest_fileinfo)
|
||||
{
|
||||
type = g_file_info_get_attribute_uint32 (dest_fileinfo, "standard::type");
|
||||
if (type != G_FILE_TYPE_DIRECTORY)
|
||||
{
|
||||
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
|
||||
"Attempting to replace non-directory %s with directory %s",
|
||||
dest_path, src_path);
|
||||
goto out;
|
||||
}
|
||||
|
||||
src_enum = g_file_enumerate_children (src, OSTREE_GIO_FAST_QUERYINFO,
|
||||
G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS,
|
||||
cancellable, error);
|
||||
if (!src_enum)
|
||||
goto out;
|
||||
|
||||
while ((src_fileinfo = g_file_enumerator_next_file (src_enum, cancellable, &temp_error)) != NULL)
|
||||
{
|
||||
type = g_file_info_get_attribute_uint32 (src_fileinfo, "standard::type");
|
||||
name = g_file_info_get_attribute_byte_string (src_fileinfo, "standard::name");
|
||||
|
||||
dest_subfile = g_file_get_child (destination, name);
|
||||
src_subfile = g_file_get_child (src, name);
|
||||
|
||||
if (type == G_FILE_TYPE_DIRECTORY)
|
||||
{
|
||||
if (!ot_gfile_merge_dirs (dest_subfile, src_subfile, cancellable, error))
|
||||
goto out;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!g_file_move (src_subfile, dest_subfile,
|
||||
move_flags, NULL, NULL, cancellable, error))
|
||||
goto out;
|
||||
}
|
||||
|
||||
g_clear_object (&dest_subfile);
|
||||
g_clear_object (&src_subfile);
|
||||
}
|
||||
if (temp_error)
|
||||
{
|
||||
g_propagate_error (error, temp_error);
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
else if (g_error_matches (temp_error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND))
|
||||
{
|
||||
g_clear_error (&temp_error);
|
||||
if (!g_file_move (src, destination, move_flags, NULL, NULL, cancellable, error))
|
||||
goto out;
|
||||
}
|
||||
else
|
||||
goto out;
|
||||
|
||||
(void) rmdir (ot_gfile_get_path_cached (src));
|
||||
|
||||
ret = TRUE;
|
||||
out:
|
||||
return ret;
|
||||
}
|
||||
|
@ -96,11 +96,6 @@ guchar * ot_gio_checksum_stream_finish (GInputStream *in,
|
||||
GAsyncResult *result,
|
||||
GError **error);
|
||||
|
||||
gboolean ot_gfile_merge_dirs (GFile *destination,
|
||||
GFile *src,
|
||||
GCancellable *cancellable,
|
||||
GError **error);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user