]> git.ipfire.org Git - thirdparty/snapper.git/commitdiff
Add date attribute to SnapshotMeta
authorCheng-Ling Lai <jameslai.tech@gmail.com>
Tue, 4 Aug 2026 02:55:28 +0000 (10:55 +0800)
committerCheng-Ling Lai <jameslai.tech@gmail.com>
Tue, 4 Aug 2026 03:07:15 +0000 (11:07 +0800)
client/snbk/CmdMetaParse.cc
client/snbk/CmdMetaParse.h
client/snbk/TheBigThing.cc
client/snbk/TheBigThing.h
client/snbk/cmd-list.cc

index d1b8dabae5680b5c4e887d3e0aa615015e39cb77..d72d48690d83cd7bd68d899d70dd4bff680520cf 100644 (file)
@@ -27,6 +27,7 @@
 #include <boost/algorithm/string.hpp>
 #include <openssl/sha.h>
 
+#include <snapper/AppUtil.h>
 #include <snapper/Enum.h>
 #include <snapper/LoggerImpl.h>
 #include <snapper/SystemCmd.h>
@@ -100,6 +101,18 @@ namespace snapper
        const xmlNode* node = file.getRootElement();
        string tmp;
 
+       time_t tmp_date;
+       if (!getChildValue(node, "date", tmp) ||
+           (tmp_date = scan_datetime(tmp, true)) == (time_t)(-1))
+       {
+           y2err("The date attribute is missing or invalid from " << path);
+           SN_THROW(Exception(_("Failed to parse the date attribute from `info.xml`")));
+       }
+       else
+       {
+           meta.date = tmp_date;
+       }
+
        if (!getChildValue(node, "type", tmp) || !toValue(tmp, meta.type, true))
        {
            y2err("The type attribute is missing from " << path);
index 5341895ad99a86aa9807e6fbb5ca6ca5749de15f..689683a4733aac5ddd0fdcfc1c39b01dc1cfbb1c 100644 (file)
@@ -55,6 +55,8 @@ namespace snapper
        };
 
        State state = State::INVALID;
+
+       time_t date = 0;
        SnapshotType type = SnapshotType::SINGLE;
        unsigned int pre_num = 0;
        string cleanup;
index 91d1252e5e582564efd2879ea7b0a73df73fd0c2..0ea6965f84ed59eca0b5be5891822f8e69f85890 100644 (file)
@@ -507,7 +507,7 @@ namespace snapper
                                            "/" SNAPSHOT_NAME);
 
            TheBigThing the_big_thing(num);
-           the_big_thing.date = source_snapshot.getDate();
+           the_big_thing.meta.date = source_snapshot.getDate();
            the_big_thing.source_state = extra.is_read_only() ? TheBigThing::SourceState::READ_ONLY :
                TheBigThing::SourceState::READ_WRITE;
            the_big_thing.source_uuid = extra.get_uuid();
index 2efcc42a8af5c648a4dd74a3d40dc5eb956a5ee1..2080133456c6a6fcd7d7f058b192d564cda9fdf5 100644 (file)
@@ -75,7 +75,6 @@ namespace snapper
        void remove(const BackupConfig& backup_config, bool quiet);
 
        unsigned int num;
-       time_t date = 0;        // as reported by snapper
 
        SourceState source_state = SourceState::MISSING;
        TargetState target_state = TargetState::MISSING;
index 6b1ec7a31bedd90e2738415c647b8d1c997d9906..e8bf80b06a1989191ebf75a3a077b1fddbe2c865 100644 (file)
@@ -135,9 +135,10 @@ namespace snapper
                    return the_big_thing.num;
 
                case Column::DATE:
-                   if (the_big_thing.date == 0)
+                   if (the_big_thing.meta.date == 0)
                        return nullptr;
-                   return datetime(the_big_thing.date, output_options.utc, output_options.iso);
+                   return datetime(the_big_thing.meta.date, output_options.utc,
+                                   output_options.iso);
 
                case Column::SOURCE_STATE:
                    if (the_big_thing.source_state == TheBigThing::SourceState::MISSING)