]> git.street.me.uk Git - andy/viking.git/blobdiff - src/download.c
[QA] Output console message if g_mkdir_with_parents() is unsuccessful.
[andy/viking.git] / src / download.c
index e928a74b5c60be4f6539a6e5ca705e9c8d8cc1e6..328f60c695ce23293506902a6b287878f9e3736f 100644 (file)
@@ -61,10 +61,12 @@ static gboolean check_file_first_line(FILE* f, gchar *patterns[])
   size_t nr;
 
   memset(buf, 0, sizeof(buf));
-  fgetpos(f, &pos);
+  if ( !fgetpos(f, &pos) )
+    return FALSE;
   rewind(f);
   nr = fread(buf, 1, sizeof(buf) - 1, f);
-  fsetpos(f, &pos);
+  if ( !fgetpos(f, &pos) )
+    return FALSE;
   for (bp = buf; (bp < (buf + sizeof(buf) - 1)) && (nr > (bp - buf)); bp++) {
     if (!(isspace(*bp)))
       break;
@@ -278,7 +280,7 @@ static DownloadResult_t download( const char *hostname, const char *uri, const c
     time_t tile_age = a_preferences_get(VIKING_PREFERENCES_NAMESPACE "download_tile_age")->u;
     /* Get the modified time of this file */
     struct stat buf;
-    g_stat ( fn, &buf );
+    (void)g_stat ( fn, &buf );
     time_t file_time = buf.st_mtime;
     if ( (time(NULL) - file_time) < tile_age ) {
       /* File cache is too recent, so return */
@@ -306,7 +308,8 @@ static DownloadResult_t download( const char *hostname, const char *uri, const c
 
   } else {
     gchar *dir = g_path_get_dirname ( fn );
-    g_mkdir_with_parents ( dir , 0777 );
+    if ( g_mkdir_with_parents ( dir , 0777 ) != 0)
+      g_warning ("%s: Failed to mkdir %s", __FUNCTION__, dir );
     g_free ( dir );
   }
 
@@ -375,7 +378,7 @@ static DownloadResult_t download( const char *hostname, const char *uri, const c
   }
 
   if (ret == CURL_DOWNLOAD_NO_NEWER_FILE)  {
-    g_remove ( tmpfilename );
+    (void)g_remove ( tmpfilename );
 #if GLIB_CHECK_VERSION(2,18,0)
     g_utime ( fn, NULL ); /* update mtime of local copy */
 #else
@@ -447,7 +450,7 @@ gchar *a_download_uri_to_tmp_file ( const gchar *uri, DownloadMapOptions *option
   if ( curl_download_uri ( uri, tmp_file, options, NULL, NULL ) ) {
     // error
     fclose ( tmp_file );
-    g_remove ( tmpname );
+    (void)g_remove ( tmpname );
     g_free ( tmpname );
     return NULL;
   }