[PATCH db-tools 09/11] Explicitly set timestamps on entries in created tar file

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

 



Always set a timestamp on entries in the created tar file
to reflect the time at which the tar was created. This
ensures when people import new versions of the database,
the files get newer timestamps.

Signed-off-by: Daniel P. Berrange <berrange@xxxxxxxxxx>
---
 tools/osinfo-db-export.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/tools/osinfo-db-export.c b/tools/osinfo-db-export.c
index c79778a..52792a7 100644
--- a/tools/osinfo-db-export.c
+++ b/tools/osinfo-db-export.c
@@ -33,6 +33,7 @@
 
 const char *argv0;
 
+time_t entryts;
 
 static int osinfo_db_export_create_file(const gchar *prefix,
                                         GFile *file,
@@ -197,6 +198,11 @@ static int osinfo_db_export_create_file(const gchar *prefix,
     entry = archive_entry_new();
     archive_entry_set_pathname(entry, entpath);
 
+    archive_entry_set_atime(entry, entryts, 0);
+    archive_entry_set_ctime(entry, entryts, 0);
+    archive_entry_set_mtime(entry, entryts, 0);
+    archive_entry_set_birthtime(entry, entryts, 0);
+
     switch (type) {
     case G_FILE_TYPE_REGULAR:
     case G_FILE_TYPE_SYMBOLIC_LINK:
@@ -212,6 +218,7 @@ static int osinfo_db_export_create_file(const gchar *prefix,
         if (verbose) {
             g_print("%s: d %s\n", argv0, entpath);
         }
+
         archive_entry_set_filetype(entry, AE_IFDIR);
         archive_entry_set_perm(entry, 0755);
         archive_entry_set_size(entry, 0);
@@ -405,6 +412,7 @@ gint main(gint argc, gchar **argv)
         goto error;
     }
 
+    entryts = time(NULL);
     prefix = osinfo_db_export_prefix(version);
     archive = argc == 2 ? argv[1] : NULL;
     dir = osinfo_db_get_path(root, user, local, system, custom);
-- 
2.7.4

_______________________________________________
Libosinfo mailing list
Libosinfo@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libosinfo



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Fedora Users]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]

  Powered by Linux