[grilo/mocking: 26/27] net: Use MD5 sum instead of URL in capture files



commit e1eda52bae34e10e3d5e45fcb5c3e8c2857558e4
Author: Mathias Hasselmann <mathias openismus com>
Date:   Mon Oct 22 17:09:15 2012 +0200

    net: Use MD5 sum instead of URL in capture files
    
    Some services use extraordinary long URL that exceed file system limits

 libs/net/grl-net-private.c |   11 ++++++-----
 1 files changed, 6 insertions(+), 5 deletions(-)
---
diff --git a/libs/net/grl-net-private.c b/libs/net/grl-net-private.c
index 3ef6e21..c157f9b 100644
--- a/libs/net/grl-net-private.c
+++ b/libs/net/grl-net-private.c
@@ -111,12 +111,13 @@ init_dump_directory ()
 static char *
 build_request_filename (const char *uri)
 {
-    char *escaped_uri = g_uri_escape_string (uri, NULL, FALSE);
-    char *filename = g_strdup_printf ("%"G_GINT64_FORMAT "-%s",
-                                      g_get_monotonic_time (), escaped_uri);
+  char *hash = g_compute_checksum_for_string (G_CHECKSUM_MD5, uri, -1);
 
-    g_free (escaped_uri);
-    return filename;
+  char *filename = g_strdup_printf ("%"G_GINT64_FORMAT "-%s.data",
+                                    g_get_monotonic_time (), hash);
+
+  g_free (hash);
+  return filename;
 }
 
 void



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]