summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorMichael Catanzaro <mcatanzaro@igalia.com>2019-05-08 10:58:32 -0500
committerMichael Catanzaro <mcatanzaro@igalia.com>2019-05-08 10:58:32 -0500
commit4e998d45e4cc549a7ca561a33895b0fbcf7ba6bb (patch)
tree0ed05ed2463ebca4a8da4b15685e816e2575af61 /lib
parente0b1eef060c4af2bb00be76a13bcbef64603f69d (diff)
downloadepiphany-4e998d45e4cc549a7ca561a33895b0fbcf7ba6bb.tar.gz
web-app-utils: Clean up ephy_web_application_create()
Fixes #764
Diffstat (limited to 'lib')
-rw-r--r--lib/ephy-web-app-utils.c24
1 files changed, 10 insertions, 14 deletions
diff --git a/lib/ephy-web-app-utils.c b/lib/ephy-web-app-utils.c
index 684b84a58..64ace3fc3 100644
--- a/lib/ephy-web-app-utils.c
+++ b/lib/ephy-web-app-utils.c
@@ -374,46 +374,42 @@ ephy_web_application_create (const char *id,
const char *name,
GdkPixbuf *icon)
{
- char *profile_dir;
- char *desktop_file_path = NULL;
+ g_autofree char *app_file = NULL;
+ g_autofree char *profile_dir = NULL;
+ g_autofree char *desktop_file_path = NULL;
/* If there's already a WebApp profile for the contents of this
* view, do nothing. */
profile_dir = ephy_web_application_get_profile_directory (id);
if (g_file_test (profile_dir, G_FILE_TEST_IS_DIR)) {
g_warning ("Profile directory %s already exists", profile_dir);
- goto out;
+ return NULL;
}
/* Create the profile directory, populate it. */
if (g_mkdir_with_parents (profile_dir, 488) == -1) {
g_warning ("Failed to create directory %s", profile_dir);
- goto out;
+ return NULL;
}
/* Skip migration for new web apps. */
ephy_profile_utils_set_migration_version_for_profile_dir (EPHY_PROFILE_MIGRATION_VERSION, profile_dir);
/* Create an .app file. */
- g_autofree char *app_file = g_build_filename (profile_dir, ".app", NULL);
+ app_file = g_build_filename (profile_dir, ".app", NULL);
int fd = g_open (app_file, O_WRONLY|O_CREAT|O_TRUNC, 0644);
if (fd < 0) {
- LOG ("Failed to create .app file: %s", g_strerror (errno));
- goto out;
- } else {
- close (fd);
+ g_warning ("Failed to create .app file: %s", g_strerror (errno));
+ return NULL;
}
+ close (fd);
/* Create the deskop file. */
desktop_file_path = create_desktop_file (id, name, address, profile_dir, icon);
if (desktop_file_path)
ephy_web_application_initialize_settings (profile_dir);
- out:
- if (profile_dir)
- g_free (profile_dir);
-
- return desktop_file_path;
+ return g_steal_pointer (&desktop_file_path);
}
char *