summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel P. Berrangé <berrange@redhat.com>2021-10-05 11:24:18 +0100
committerFabiano FidĂȘncio <fabiano@fidencio.org>2021-10-10 12:20:08 +0000
commite305a15bf93a0b95f370b764001a3a34ff0f3af2 (patch)
treecb882ed161b9ad2fa8224c9958c2b2987f490a8f
parentb9cbac75b62e05c3009179a547c8ce682bd1d79e (diff)
downloadlibosinfo-e305a15bf93a0b95f370b764001a3a34ff0f3af2.tar.gz
Warn about unexpected files in the database
To help remind users that files must end in .xml, warn about any unusually named files. There are a couple of files we should not warn about since we expect them to be present - VERSION - LICENSE The entire 'schema' sub-directory should be ignored. Common editor backups "~" and ".bak" should be ignored. Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
-rw-r--r--osinfo/osinfo_loader.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/osinfo/osinfo_loader.c b/osinfo/osinfo_loader.c
index 9ec99cd..ca2c765 100644
--- a/osinfo/osinfo_loader.c
+++ b/osinfo/osinfo_loader.c
@@ -2349,9 +2349,18 @@ static void osinfo_loader_find_files(OsinfoLoader *loader,
type = g_file_info_get_attribute_uint32(info,
G_FILE_ATTRIBUTE_STANDARD_TYPE);
if (type == G_FILE_TYPE_DIRECTORY) {
- osinfo_loader_find_files(loader, base, ent, entries, FALSE, &error);
- } else if (g_str_has_suffix(name, ".xml")) {
- osinfo_loader_entity_files_add_path(entries, base, ent);
+ if (!g_str_equal(name, "schema"))
+ osinfo_loader_find_files(loader, base, ent, entries, FALSE, &error);
+ } else {
+ if (g_str_has_suffix(name, ".xml")) {
+ osinfo_loader_entity_files_add_path(entries, base, ent);
+ } else if (!g_str_equal(name, "LICENSE") &&
+ !g_str_equal(name, "VERSION") &&
+ !g_str_has_suffix(name, "~") &&
+ !g_str_has_suffix(name, ".bak")) {
+ g_autofree gchar *path = g_file_get_path(ent);
+ g_printerr("Ignoring %s with missing '.xml' extension\n", path);
+ }
}
g_object_unref(ent);
g_object_unref(info);