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();
__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;
}
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;
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);
}