[Midnightbsd-cvs] src [12286] trunk/lib/libmport/clean.c: look at hash values to help remove packages.
laffer1 at midnightbsd.org
laffer1 at midnightbsd.org
Tue Nov 12 22:39:14 EST 2019
Revision: 12286
http://svnweb.midnightbsd.org/src/?rev=12286
Author: laffer1
Date: 2019-11-12 22:39:14 -0500 (Tue, 12 Nov 2019)
Log Message:
-----------
look at hash values to help remove packages.
Modified Paths:
--------------
trunk/lib/libmport/clean.c
Modified: trunk/lib/libmport/clean.c
===================================================================
--- trunk/lib/libmport/clean.c 2019-11-13 03:34:36 UTC (rev 12285)
+++ trunk/lib/libmport/clean.c 2019-11-13 03:39:14 UTC (rev 12286)
@@ -77,12 +77,18 @@
continue;
if (mport_index_search(mport, &indexEntry, "bundlefile=%Q", de->d_name) != MPORT_OK) {
+ mport_call_msg_cb(mport, "failed to search index %s: ", mport_err_string());
continue;
}
+ asprintf(&path, "%s/%s", MPORT_FETCH_STAGING_DIR, de->d_name);
+ if (path == NULL) {
+ if (indexEntry != NULL)
+ mport_index_entry_free_vec(indexEntry);
+ continue;
+ }
+
if (indexEntry == NULL || *indexEntry == NULL) {
- asprintf(&path, "%s/%s", MPORT_FETCH_STAGING_DIR, de->d_name);
- if (path != NULL) {
if (unlink(path) < 0) {
error_code = SET_ERRORX(MPORT_ERR_FATAL, "Could not delete file %s: %s",
path, strerror(errno));
@@ -90,11 +96,26 @@
} else {
deleted++;
}
- free(path);
- }
+ } else if (mport_verify_hash(path, (*indexEntry)->hash) == 0) {
+ if (unlink(path) < 0) {
+
+ error_code = SET_ERRORX(MPORT_ERR_FATAL, "Could not delete file %s: %s",
+
+ path, strerror(errno));
+
+ mport_call_msg_cb(mport, "%s\n", mport_err_string());
+
+ } else {
+
+ deleted++;
+
+ }
+ mport_index_entry_free_vec(indexEntry);
} else {
mport_index_entry_free_vec(indexEntry);
}
+
+ free(path);
}
closedir(d);
More information about the Midnightbsd-cvs
mailing list