[pacman-dev] [PATCH 2/3] be_sync.c: Raise alpm_event_database_refresh_t events during refresh

ivy.foster at gmail.com ivy.foster at gmail.com
Mon Jul 4 01:54:33 UTC 2016


From: Ivy Foster <ivy.foster at gmail.com>

Signed-off-by: Ivy Foster <ivy.foster at gmail.com>
---
 lib/libalpm/be_sync.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/lib/libalpm/be_sync.c b/lib/libalpm/be_sync.c
index 32a669d..ad97475 100644
--- a/lib/libalpm/be_sync.c
+++ b/lib/libalpm/be_sync.c
@@ -182,6 +182,10 @@ int SYMEXPORT alpm_db_update(int force, alpm_db_t *db)
 	mode_t oldmask;
 	alpm_handle_t *handle;
 	alpm_siglevel_t level;
+	alpm_event_database_refresh_t event = {
+		.type = ALPM_EVENT_DATABASE_REFRESH_START,
+		.dbname = db->treename,
+	};
 
 	/* Sanity checks */
 	ASSERT(db != NULL, return -1);
@@ -238,6 +242,8 @@ int SYMEXPORT alpm_db_update(int force, alpm_db_t *db)
 		payload.force = force;
 		payload.unlink_on_fail = 1;
 
+		EVENT(db->handle, &event);
+
 		ret = _alpm_download(&payload, syncpath, NULL, &final_db_url);
 		_alpm_dload_payload_reset(&payload);
 		updated = (updated || ret == 0);
@@ -319,10 +325,13 @@ int SYMEXPORT alpm_db_update(int force, alpm_db_t *db)
 		/* pm_errno was set by the download code */
 		_alpm_log(handle, ALPM_LOG_DEBUG, "failed to sync db: %s\n",
 				alpm_strerror(handle->pm_errno));
+		event.type = ALPM_EVENT_DATABASE_REFRESH_FAILED;
 	} else {
 		handle->pm_errno = 0;
+		event.type = ALPM_EVENT_DATABASE_REFRESH_DONE;
 	}
 
+	EVENT(db->handle, &event);
 	_alpm_handle_unlock(handle);
 	free(syncpath);
 	umask(oldmask);
-- 
2.9.0


More information about the pacman-dev mailing list