aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorClaudio Saavedra <csaavedra@igalia.com>2013-01-28 00:02:53 +0800
committerClaudio Saavedra <csaavedra@igalia.com>2013-01-28 00:02:53 +0800
commit9483e9e52af9b36ad41215063b616e960928d78a (patch)
tree7f8eb94758808f74871dd9ff9833434a1685ce49 /lib
parent213b032a24ac9286af1f5ab3a4087d64eef12f52 (diff)
downloadgsoc2013-epiphany-9483e9e52af9b36ad41215063b616e960928d78a.tar
gsoc2013-epiphany-9483e9e52af9b36ad41215063b616e960928d78a.tar.gz
gsoc2013-epiphany-9483e9e52af9b36ad41215063b616e960928d78a.tar.bz2
gsoc2013-epiphany-9483e9e52af9b36ad41215063b616e960928d78a.tar.lz
gsoc2013-epiphany-9483e9e52af9b36ad41215063b616e960928d78a.tar.xz
gsoc2013-epiphany-9483e9e52af9b36ad41215063b616e960928d78a.tar.zst
gsoc2013-epiphany-9483e9e52af9b36ad41215063b616e960928d78a.zip
ephy-file-helpers: remove ephy_file_switch_temp_file()
It is racy and it is unnecessary as we've replaced all its instances with g_file_set_contents().
Diffstat (limited to 'lib')
-rw-r--r--lib/ephy-file-helpers.c109
-rw-r--r--lib/ephy-file-helpers.h2
2 files changed, 0 insertions, 111 deletions
diff --git a/lib/ephy-file-helpers.c b/lib/ephy-file-helpers.c
index b21b8a7f5..a55d45389 100644
--- a/lib/ephy-file-helpers.c
+++ b/lib/ephy-file-helpers.c
@@ -551,115 +551,6 @@ ephy_file_find (const char *path,
}
/**
- * ephy_file_switch_temp_file:
- * @file_dest: destination file
- * @file_temp: file to move to @file
- *
- * Moves @file_temp to @file_dest atomically, doing a backup and restoring it if
- * something fails.
- *
- * Returns: %TRUE if the switch was successful
- **/
-gboolean
-ephy_file_switch_temp_file (GFile *file_dest,
- GFile *file_temp)
-{
- char *file_dest_path, *file_temp_path;
- char *backup_path;
- gboolean dest_exists;
- gboolean retval = TRUE;
- GFile *backup_file;
- GError *error = NULL;
-
- file_dest_path = g_file_get_path (file_dest);
- file_temp_path = g_file_get_path (file_temp);
-
- dest_exists = g_file_test (file_dest_path, G_FILE_TEST_EXISTS);
-
- backup_path = g_strconcat (file_dest_path, ".old", NULL);
- backup_file = g_file_new_for_path (backup_path);
-
- if (dest_exists)
- {
- if (g_file_move (file_dest, backup_file,
- G_FILE_COPY_OVERWRITE,
- NULL, NULL, NULL, &error) == FALSE)
- {
- g_warning ("Failed to backup %s to %s: %s",
- file_dest_path, backup_path,
- error ? error->message : "No error set");
-
- if (error)
- {
- g_error_free (error);
- error = NULL;
- }
-
- retval = FALSE;
- goto failed;
- }
- }
-
- if (g_file_move (file_temp, file_dest,
- G_FILE_COPY_OVERWRITE,
- NULL, NULL, NULL, &error) == FALSE)
- {
- g_warning ("Failed to replace %s with %s: %s",
- file_temp_path, file_dest_path,
- error ? error->message : "No error set");
-
- if (error)
- {
- g_error_free (error);
- error = NULL;
- }
-
- if (g_file_move (backup_file, file_dest,
- G_FILE_COPY_OVERWRITE,
- NULL, NULL, NULL, &error) == FALSE)
- {
- g_warning ("Failed to restore %s from %s: %s",
- file_dest_path, file_temp_path,
- error ? error->message : "No error set");
-
- if (error)
- {
- g_error_free (error);
- error = NULL;
- }
- }
-
- retval = FALSE;
- goto failed;
- }
-
- if (dest_exists)
- {
- if (g_file_delete (backup_file, NULL, &error) == FALSE)
- {
- g_warning ("Failed to delete old file %s: %s",
- backup_path,
- error ? error->message : "No error set");
-
- if (error)
- {
- g_error_free (error);
- error = NULL;
- }
- }
- }
-
-failed:
- g_free (file_dest_path);
- g_free (file_temp_path);
-
- g_free (backup_path);
- g_object_unref (backup_file);
-
- return retval;
-}
-
-/**
* ephy_file_delete_on_exit:
* @file: a #GFile
*
diff --git a/lib/ephy-file-helpers.h b/lib/ephy-file-helpers.h
index 5eed9edf7..28c83b24b 100644
--- a/lib/ephy-file-helpers.h
+++ b/lib/ephy-file-helpers.h
@@ -68,8 +68,6 @@ gboolean ephy_ensure_dir_exists (const char
GSList * ephy_file_find (const char *path,
const char *fname,
gint maxdepth);
-gboolean ephy_file_switch_temp_file (GFile *file_dest,
- GFile *file_temp);
void ephy_file_delete_on_exit (GFile *file);
EphyMimePermission ephy_file_check_mime (const char *mime_type);
gboolean ephy_file_launch_desktop_file (const char *filename,