]> git.ipfire.org Git - pakfire.git/commitdiff
repo: Use the new progress implementation
authorMichael Tremer <michael.tremer@ipfire.org>
Sun, 1 Oct 2023 11:21:57 +0000 (11:21 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Sun, 1 Oct 2023 11:21:57 +0000 (11:21 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/libpakfire/repo.c

index b670bcee92b6d9ed71dc6907f11376d998a3d2bc..2c89269d64cc95e9c180be32eea679470cd0a3aa 100644 (file)
@@ -43,7 +43,7 @@
 #include <pakfire/package.h>
 #include <pakfire/pakfire.h>
 #include <pakfire/private.h>
-#include <pakfire/progressbar.h>
+#include <pakfire/progress.h>
 #include <pakfire/repo.h>
 #include <pakfire/string.h>
 #include <pakfire/util.h>
@@ -1344,7 +1344,7 @@ ERROR:
 
 PAKFIRE_EXPORT int pakfire_repo_scan(struct pakfire_repo* repo, int flags) {
        struct pakfire_filelist* filelist = NULL;
-       struct pakfire_progressbar* progressbar = NULL;
+       struct pakfire_progress* progress = NULL;
        int r;
 
        const char* path = pakfire_repo_get_path(repo);
@@ -1368,36 +1368,27 @@ PAKFIRE_EXPORT int pakfire_repo_scan(struct pakfire_repo* repo, int flags) {
        // Fetch how many files have been found
        const size_t num_files = pakfire_filelist_length(filelist);
 
-       // Create progressbar
-       r = pakfire_progressbar_create(&progressbar, NULL);
+       // Create progress indicator
+       r = pakfire_progress_create(&progress, repo->pakfire,
+               PAKFIRE_PROGRESS_SHOW_COUNTER|PAKFIRE_PROGRESS_SHOW_ELAPSED_TIME);
        if (r)
                goto ERROR;
 
        const char* name = pakfire_repo_get_name(repo);
 
-       // Add title to progressbar
-       r = pakfire_progressbar_add_string(progressbar, _("Scanning %s"), name);
+       // Add title to progress
+       r = pakfire_progress_set_title(progress, _("Scanning %s"), name);
        if (r)
                goto ERROR;
 
-       // Add the bar
-       r = pakfire_progressbar_add_bar(progressbar);
-       if (r)
-               goto ERROR;
-
-       // Add a counter
-       r = pakfire_progressbar_add_counter(progressbar);
-       if (r)
-               goto ERROR;
-
-       // Start progress bar
-       r = pakfire_progressbar_start(progressbar, num_files);
+       // Start progress
+       r = pakfire_progress_start(progress, num_files);
 
        for (unsigned int i = 0; i < num_files; i++) {
                struct pakfire_file* file = pakfire_filelist_get(filelist, i);
 
                // Increment progress bar
-               pakfire_progressbar_increment(progressbar, 1);
+               pakfire_progress_increment(progress, 1);
 
                // Skip anything that isn't a regular file
                int type = pakfire_file_get_type(file);
@@ -1421,8 +1412,8 @@ PAKFIRE_EXPORT int pakfire_repo_scan(struct pakfire_repo* repo, int flags) {
        // Mark repository data as changed
        pakfire_repo_has_changed(repo);
 
-       // Finish the progress bar
-       r = pakfire_progressbar_finish(progressbar);
+       // Finish the progress
+       r = pakfire_progress_finish(progress);
        if (r)
                goto ERROR;
 
@@ -1430,8 +1421,8 @@ PAKFIRE_EXPORT int pakfire_repo_scan(struct pakfire_repo* repo, int flags) {
        r = 0;
 
 ERROR:
-       if (progressbar)
-               pakfire_progressbar_unref(progressbar);
+       if (progress)
+               pakfire_progress_unref(progress);
        if (filelist)
                pakfire_filelist_unref(filelist);