[pacman-dev] [PATCH 1/2] Add function to set and get expiry time for a repo database

Allan McRae allan at archlinux.org
Fri Dec 13 11:32:43 UTC 2019


Signed-off-by: Allan McRae <allan at archlinux.org>
---
 lib/libalpm/alpm.h | 14 ++++++++++++++
 lib/libalpm/db.c   | 14 ++++++++++++++
 lib/libalpm/db.h   |  2 ++
 3 files changed, 30 insertions(+)

diff --git a/lib/libalpm/alpm.h b/lib/libalpm/alpm.h
index 956284bd..0a4d7fe7 100644
--- a/lib/libalpm/alpm.h
+++ b/lib/libalpm/alpm.h
@@ -1026,6 +1026,20 @@ int alpm_db_set_usage(alpm_db_t *db, int usage);
  */
 int alpm_db_get_usage(alpm_db_t *db, int *usage);
 
+
+/** Sets the expiry time of a database.
+ * @param db pointer to the package database to set the status for
+ * @param expiry number of days old a database can be before expiry
+ * @return 0 on success, or -1 on error
+ */
+int alpm_db_set_expiry(alpm_db_t *db, int expiry);
+
+/** Gets the expiry time of a database.
+ * @param db pointer to the package database to get the status of
+ * @return expiry time
+ */
+int alpm_db_get_expiry(alpm_db_t *db);
+
 /** @} */
 
 /** @addtogroup alpm_api_packages Package Functions
diff --git a/lib/libalpm/db.c b/lib/libalpm/db.c
index 43ca1fc8..a4fd4353 100644
--- a/lib/libalpm/db.c
+++ b/lib/libalpm/db.c
@@ -325,6 +325,20 @@ int SYMEXPORT alpm_db_get_usage(alpm_db_t *db, int *usage)
 	return 0;
 }
 
+/** Sets the expiry time for a repo */
+int SYMEXPORT alpm_db_set_expiry(alpm_db_t *db, int expiry)
+{
+	ASSERT(db != NULL, return -1);
+	db->expiry = expiry;
+	return 0;
+}
+
+/** Gets the expiry time for a repo */
+int SYMEXPORT alpm_db_get_expiry(alpm_db_t *db)
+{
+	ASSERT(db != NULL, return -1);
+	return db->expiry;
+}
 
 /** @} */
 
diff --git a/lib/libalpm/db.h b/lib/libalpm/db.h
index e7ad98f5..76947247 100644
--- a/lib/libalpm/db.h
+++ b/lib/libalpm/db.h
@@ -79,6 +79,8 @@ struct __alpm_db_t {
 	int siglevel;
 	/* alpm_db_usage_t */
 	int usage;
+
+	int expiry;
 };
 
 
-- 
2.24.1


More information about the pacman-dev mailing list