From: Cheng-Ling Lai Date: Tue, 4 Aug 2026 02:55:28 +0000 (+0800) Subject: Add date attribute to SnapshotMeta X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=cb0a454c5d77a63d80b77a332671ea6c3826f97d;p=thirdparty%2Fsnapper.git Add date attribute to SnapshotMeta --- diff --git a/client/snbk/CmdMetaParse.cc b/client/snbk/CmdMetaParse.cc index d1b8daba..d72d4869 100644 --- a/client/snbk/CmdMetaParse.cc +++ b/client/snbk/CmdMetaParse.cc @@ -27,6 +27,7 @@ #include #include +#include #include #include #include @@ -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); diff --git a/client/snbk/CmdMetaParse.h b/client/snbk/CmdMetaParse.h index 5341895a..689683a4 100644 --- a/client/snbk/CmdMetaParse.h +++ b/client/snbk/CmdMetaParse.h @@ -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; diff --git a/client/snbk/TheBigThing.cc b/client/snbk/TheBigThing.cc index 91d1252e..0ea6965f 100644 --- a/client/snbk/TheBigThing.cc +++ b/client/snbk/TheBigThing.cc @@ -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(); diff --git a/client/snbk/TheBigThing.h b/client/snbk/TheBigThing.h index 2efcc42a..20801334 100644 --- a/client/snbk/TheBigThing.h +++ b/client/snbk/TheBigThing.h @@ -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; diff --git a/client/snbk/cmd-list.cc b/client/snbk/cmd-list.cc index 6b1ec7a3..e8bf80b0 100644 --- a/client/snbk/cmd-list.cc +++ b/client/snbk/cmd-list.cc @@ -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)