uninstall: When uninstalling the current branch, make other version current (if any)

tingping/wmclass
Alexander Larsson 2016-05-26 20:03:51 +02:00
parent 9ec3e7346b
commit 1d8408e381
1 changed files with 28 additions and 1 deletions

View File

@ -1537,13 +1537,40 @@ flatpak_dir_drop_current_ref (FlatpakDir *self,
g_autoptr(GFile) base = NULL;
g_autoptr(GFile) dir = NULL;
g_autoptr(GFile) current_link = NULL;
g_auto(GStrv) refs = NULL;
g_autofree char *current_ref = NULL;
const char *other_ref = NULL;
base = g_file_get_child (flatpak_dir_get_path (self), "app");
dir = g_file_get_child (base, name);
current_ref = flatpak_dir_current_ref (self, name, cancellable);
if (flatpak_dir_list_refs_for_name (self, "app", name, &refs, cancellable, NULL))
{
int i;
for (i = 0; refs[i] != NULL; i++)
{
if (g_strcmp0 (refs[i], current_ref) != 0)
{
other_ref = refs[i];
break;
}
}
}
current_link = g_file_get_child (dir, "current");
return g_file_delete (current_link, cancellable, error);
if (!g_file_delete (current_link, cancellable, error))
return FALSE;
if (other_ref)
{
if (!flatpak_dir_make_current_ref (self, other_ref, cancellable, error))
return FALSE;
}
return TRUE;
}
gboolean