Remove status_file_tmp_name. This code does not improve robustness.
authorgraham.gower <graham.gower@e8e0d7a0-c8d9-11dd-a880-a1081c7ac358>
Fri, 13 Nov 2009 02:57:43 +0000 (02:57 +0000)
committergraham.gower <graham.gower@e8e0d7a0-c8d9-11dd-a880-a1081c7ac358>
Fri, 13 Nov 2009 02:57:43 +0000 (02:57 +0000)
git-svn-id: http://opkg.googlecode.com/svn/trunk@296 e8e0d7a0-c8d9-11dd-a880-a1081c7ac358

libopkg/opkg_conf.c
libopkg/pkg_dest.c
libopkg/pkg_dest.h

index 47e11ece44e15f93d45e890209076d5efbb3a5f4..dc2c5f9ea414cba098aa79cfc696da55da484276 100644 (file)
@@ -688,17 +688,18 @@ int opkg_conf_write_status_files(opkg_conf_t *conf)
      pkg_vec_t *all;
      pkg_t *pkg;
      int i;
-     int err;
-     FILE * status_file=NULL;
+     FILE *fp;
 
      if (conf->noaction)
          return 0;
 
      dest = (pkg_dest_t *)void_list_first(&conf->pkg_dest_list)->data;
-     status_file = fopen(dest->status_file_tmp_name, "w");
-     if (status_file == NULL) {
+
+     fp = fopen(dest->status_file_name, "w");
+     if (fp == NULL) {
          fprintf(stderr, "%s: Can't open status file: %s for writing: %s\n",
-                 __FUNCTION__, dest->status_file_tmp_name, strerror(errno));
+                 __FUNCTION__, dest->status_file_name, strerror(errno));
+        return -1;
      }
 
      all = pkg_vec_alloc();
@@ -719,25 +720,12 @@ int opkg_conf_write_status_files(opkg_conf_t *conf)
                       __FUNCTION__, pkg->name);
               continue;
          }
-         if (status_file) {
-              pkg_print_status(pkg, status_file);
-         }
+         pkg_print_status(pkg, fp);
      }
 
      pkg_vec_free(all);
+     fclose(fp);
 
-     if (status_file) {
-         err = ferror(status_file);
-         fclose(status_file);
-         if (!err) {
-             file_move(dest->status_file_tmp_name, dest->status_file_name);
-         } else {
-             fprintf(stderr, "%s: ERROR: An error has occurred writing %s, "
-                     "retaining old %s\n", __FUNCTION__,
-                     dest->status_file_tmp_name, dest->status_file_name);
-         }
-         status_file = NULL;
-     }
      return 0;
 }
 
index b1b502ace75be540d8bb314b70856804b6d4ee2c..2adaf62eae6acd7fcabb18a0e5164abbc745a1c8 100644 (file)
@@ -56,9 +56,6 @@ int pkg_dest_init(pkg_dest_t *dest, const char *name, const char *root_dir,const
     sprintf_alloc(&dest->status_file_name, "%s/%s",
                  dest->opkg_dir, OPKG_STATUS_FILE_SUFFIX);
 
-    sprintf_alloc(&dest->status_file_tmp_name, "%s/%s.tmp",
-                 dest->opkg_dir, OPKG_STATUS_FILE_SUFFIX);
-
     dest->status_file = NULL;
 
     return 0;
@@ -84,9 +81,6 @@ void pkg_dest_deinit(pkg_dest_t *dest)
     free(dest->status_file_name);
     dest->status_file_name = NULL;
 
-    free(dest->status_file_tmp_name);
-    dest->status_file_tmp_name = NULL;
-
     if (dest->status_file) {
        fclose(dest->status_file);
     }
index d5d5b3c2830ce2fb9f9ec7c0ea16e0c30bff4cc9..0966a9cc012547ffac0a6b9eec0745858b958951 100644 (file)
@@ -29,7 +29,6 @@ struct pkg_dest
     char *lists_dir;
     char *info_dir;
     char *status_file_name;
-    char *status_file_tmp_name;
     FILE *status_file;
 };