[gnome-software: 19/20] fedora-pkgdb-collections: Delete cache file if it’s invalid




commit 5bd6404646fd312edffdf59c4e612f428dca6e4b
Author: Philip Withnall <pwithnall endlessos org>
Date:   Fri Mar 11 14:11:36 2022 +0000

    fedora-pkgdb-collections: Delete cache file if it’s invalid
    
    This means the next time the ODRS data is refreshed, the file will be
    downloaded again, which gives a chance for it to be updated to something
    valid.
    
    Signed-off-by: Philip Withnall <pwithnall endlessos org>

 .../fedora-pkgdb-collections/gs-plugin-fedora-pkgdb-collections.c    | 5 +++++
 1 file changed, 5 insertions(+)
---
diff --git a/plugins/fedora-pkgdb-collections/gs-plugin-fedora-pkgdb-collections.c 
b/plugins/fedora-pkgdb-collections/gs-plugin-fedora-pkgdb-collections.c
index bdafea58b..ad51d4fb4 100644
--- a/plugins/fedora-pkgdb-collections/gs-plugin-fedora-pkgdb-collections.c
+++ b/plugins/fedora-pkgdb-collections/gs-plugin-fedora-pkgdb-collections.c
@@ -599,6 +599,11 @@ ensure_refresh_cb (GObject      *source_object,
 
        distros = load_json (self, &local_error);
        if (distros == NULL) {
+               g_autoptr(GFile) cache_file = g_file_new_for_path (self->cachefn);
+
+               g_debug ("Failed to load cache file ‘%s’, deleting it", self->cachefn);
+               g_file_delete (cache_file, NULL, NULL);
+
                g_task_return_error (task, g_steal_pointer (&local_error));
                return;
        }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]