diff options
author | Patrick Griffis <pgriffis@igalia.com> | 2018-12-24 09:34:29 -0500 |
---|---|---|
committer | Michael Catanzaro <mcatanzaro@igalia.com> | 2019-01-31 16:28:58 -0600 |
commit | dd73a2aec43318372445ab74ad32d36c4b4e1879 (patch) | |
tree | f05b803ae5251c467eedcbb60dffaa93b69a98be /lib/ephy-web-app-utils.c | |
parent | f44e87ec548d7efad27b67b7327f3d0d17ebd168 (diff) | |
download | epiphany-dd73a2aec43318372445ab74ad32d36c4b4e1879.tar.gz |
Fix web app tests
Diffstat (limited to 'lib/ephy-web-app-utils.c')
-rw-r--r-- | lib/ephy-web-app-utils.c | 29 |
1 files changed, 26 insertions, 3 deletions
diff --git a/lib/ephy-web-app-utils.c b/lib/ephy-web-app-utils.c index da0957162..01b38a2f9 100644 --- a/lib/ephy-web-app-utils.c +++ b/lib/ephy-web-app-utils.c @@ -31,6 +31,7 @@ #include <libsoup/soup.h> #include <stdlib.h> #include <string.h> +#include <fcntl.h> /* Web Apps are installed in the default config dir of the user. * Every app has its own profile directory. To create a web app @@ -114,8 +115,20 @@ ephy_web_application_get_program_name_from_profile_directory (const char *profil { const char *name; - name = strstr (profile_dir, EPHY_WEB_APP_PROGRAM_NAME_PREFIX); - if (!name) { + // Just get the basename + name = strrchr (profile_dir, G_DIR_SEPARATOR); + if (name == NULL) { + g_warning ("Profile directoroy %s is not a valid path", profile_dir); + return NULL; + } + + name++; // Strip '/' + + // Legacy web app support + if (g_str_has_prefix (name, "app-")) + name += strlen ("app-"); + + if (!g_str_has_prefix (name, EPHY_WEB_APP_PROGRAM_NAME_PREFIX)) { g_warning ("Profile directory %s does not begin with required web app prefix %s", profile_dir, EPHY_WEB_APP_PROGRAM_NAME_PREFIX); return NULL; } @@ -341,11 +354,21 @@ ephy_web_application_create (const char *id, } /* Create the profile directory, populate it. */ - if (g_mkdir (profile_dir, 488) == -1) { + if (g_mkdir_with_parents (profile_dir, 488) == -1) { g_warning ("Failed to create directory %s", profile_dir); goto out; } + /* Create an .app file. */ + g_autofree char *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); + } + /* Create the deskop file. */ desktop_file_path = create_desktop_file (id, name, address, profile_dir, icon); if (desktop_file_path) |