]> Pileus Git - grits/blobdiff - src/data/gis-http.c
Move gdk_pixbuf calls to main thread
[grits] / src / data / gis-http.c
index 613dd439fa7ce38f7c55486415cf5a1a8cc8d15a..f4c4ec5b4046f891990a23d9c6c762842eb9ff42 100644 (file)
@@ -123,9 +123,7 @@ static void _chunk_cb(SoupMessage *message, SoupBuffer *chunk, gpointer _info)
 gchar *gis_http_fetch(GisHttp *http, const gchar *uri, const char *local,
                GisCacheType mode, GisChunkCallback callback, gpointer user_data)
 {
-       g_debug("GisHttp: fetch - %s... >> %s/%s  mode=%d",
-                       uri, http->prefix, local, mode);
-
+       g_debug("GisHttp: fetch - %s mode=%d", local, mode);
        gchar *path = _get_cache_path(http, local);
 
        /* Unlink the file if we're refreshing it */
@@ -141,7 +139,8 @@ gchar *gis_http_fetch(GisHttp *http, const gchar *uri, const char *local,
                gchar *part = path;
                if (!g_file_test(path, G_FILE_TEST_EXISTS))
                        part = g_strdup_printf("%s.part", path);
-               FILE *fp = fopen_p(part, "a");
+               FILE *fp = fopen_p(part, "ab");
+               fseek(fp, 0, SEEK_END); // "a" is broken on Windows, twice
 
                /* Make temp data */
                struct _CacheInfo info = {
@@ -178,6 +177,7 @@ gchar *gis_http_fetch(GisHttp *http, const gchar *uri, const char *local,
                }
        }
 
+
        /* TODO: free everything.. */
        return path;
 }
@@ -217,15 +217,17 @@ GList *gis_http_available(GisHttp *http,
                        if (g_regex_match(filter_re, file, 0, NULL))
                                files = g_list_prepend(files, g_strdup(file));
                g_free(path);
+               g_dir_close(dir);
        }
 
-
        /* Add online files if online */
        if (index) {
                gchar tmp[16];
                g_snprintf(tmp, sizeof(tmp), ".index.%x", g_random_int());
                gchar *path = gis_http_fetch(http, index, tmp,
                                GIS_REFRESH, NULL, NULL);
+               if (!path)
+                       return files;
                gchar *html;
                g_file_get_contents(path, &html, NULL, NULL);
 
@@ -243,11 +245,14 @@ GList *gis_http_available(GisHttp *http,
                        g_match_info_next(info, NULL);
                }
 
+               g_regex_unref(extract_re);
                g_match_info_free(info);
                g_unlink(path);
                g_free(path);
                g_free(html);
        }
 
+       g_regex_unref(filter_re);
+
        return files;
 }