return pakfire_file_ref(element->file);
}
+/*
+ Checks if the file is already on the list
+*/
+static int pakfire_filelist_has_file(struct pakfire_filelist* list, struct pakfire_file* file) {
+ struct pakfire_filelist_element* e = NULL;
+
+ TAILQ_FOREACH(e, &list->files, nodes) {
+ if (e->file == file)
+ return 1;
+ }
+
+ return 0;
+}
+
PAKFIRE_EXPORT int pakfire_filelist_add(struct pakfire_filelist* list, struct pakfire_file* file) {
struct pakfire_filelist_element* element = NULL;
struct pakfire_filelist_element* e = NULL;
+ // Do not do anything if the file is already on the list
+ if (pakfire_filelist_has_file(list, file))
+ return 0;
+
// Allocate a new element
element = calloc(1, sizeof *element);
if (!element) {