summaryrefslogtreecommitdiff
path: root/common/flatpak-utils.c
diff options
context:
space:
mode:
authorAlexander Larsson <alexl@redhat.com>2016-05-09 12:21:28 +0200
committerAlexander Larsson <alexl@redhat.com>2016-05-09 12:21:28 +0200
commit5e9b247d260ff4e2b9a9620053e61e8a0161cdee (patch)
tree11a05b05d1c7d6d2db8f58519630e3de8e22b6fc /common/flatpak-utils.c
parent8abbc0186efe977cec2a3214e7aa3703e9f1169f (diff)
downloadxdg-app-5e9b247d260ff4e2b9a9620053e61e8a0161cdee.tar.gz
Migrate ~/.local/share/xdg-app to ~/.local/share/flatpak
Diffstat (limited to 'common/flatpak-utils.c')
-rw-r--r--common/flatpak-utils.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/common/flatpak-utils.c b/common/flatpak-utils.c
index fca297a..b79e276 100644
--- a/common/flatpak-utils.c
+++ b/common/flatpak-utils.c
@@ -26,6 +26,7 @@
#include <string.h>
#include <stdlib.h>
+#include <stdio.h>
#include <errno.h>
#include <fcntl.h>
#include <string.h>
@@ -252,6 +253,29 @@ flatpak_get_bwrap (void)
return HELPER;
}
+/* We only migrate the user dir, because thats what most people used with xdg-app,
+ * and its where all per-user state/config are stored.
+ */
+void
+flatpak_migrate_from_xdg_app (void)
+{
+ g_autofree char *source = g_build_filename (g_get_user_data_dir (), "xdg-app", NULL);
+ g_autofree char *dest = g_build_filename (g_get_user_data_dir (), "flatpak", NULL);
+
+ if (!g_file_test (dest, G_FILE_TEST_EXISTS) &&
+ g_file_test (source, G_FILE_TEST_EXISTS))
+ {
+ g_print ("Migrating %s to %s\n", source, dest);
+ if (rename (source, dest) != 0)
+ {
+ if (errno != ENOENT &&
+ errno != ENOTEMPTY &&
+ errno != EEXIST)
+ g_print ("Error during migration: %s\n", strerror (errno));
+ }
+ }
+}
+
static gboolean
is_valid_initial_name_character (gint c)
{