diff --git a/src/dwarfs/metadata_v2.cpp b/src/dwarfs/metadata_v2.cpp index a2a9f032..fe8a6543 100644 --- a/src/dwarfs/metadata_v2.cpp +++ b/src/dwarfs/metadata_v2.cpp @@ -24,6 +24,7 @@ #include #include #include +#include #include #include @@ -574,6 +575,13 @@ void metadata_::dump( os << "created by: " << *version << std::endl; } + if (auto ts = meta_.create_timestamp()) { + time_t tp = *ts; + std::string str(20, '\0'); + std::strftime(str.data(), str.size(), "%F %T", std::localtime(&tp)); + os << "created on: " << str << std::endl; + } + if (detail_level > 0) { os << "block size: " << stbuf.f_bsize << std::endl; os << "inode count: " << stbuf.f_files << std::endl; diff --git a/src/dwarfs/scanner.cpp b/src/dwarfs/scanner.cpp index c21aa2f9..8b3dab1c 100644 --- a/src/dwarfs/scanner.cpp +++ b/src/dwarfs/scanner.cpp @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include @@ -726,6 +727,7 @@ void scanner_::scan(filesystem_writer& fsw, mv2.total_hardlink_size_ref() = prog.hardlink_size; mv2.options_ref() = fsopts; mv2.dwarfs_version_ref() = std::string("libdwarfs ") + PRJ_GIT_ID; + mv2.create_timestamp_ref() = std::time(nullptr); auto [schema, data] = metadata_v2::freeze(mv2); diff --git a/thrift/metadata.thrift b/thrift/metadata.thrift index 05df8f91..1ee05635 100644 --- a/thrift/metadata.thrift +++ b/thrift/metadata.thrift @@ -238,6 +238,6 @@ struct metadata { // version 22: optional string dwarfs_version, - // TODO: add timestamp - // 21: optional UInt64 timestamp, + // timestamp + 23: optional UInt64 create_timestamp, }