58 version_checker() =
delete;
60 version_checker(version_checker
const &) =
default;
61 version_checker & operator=(version_checker
const &) =
default;
62 version_checker(version_checker &&) =
default;
63 version_checker & operator=(version_checker &&) =
default;
64 ~version_checker() =
default;
72 name{std::move(name_)}
76 message_app_update.pop_back();
77 message_app_update.append(
"[APP INFO] :: Visit " + app_url +
" for updates.\n\n");
81 timestamp_filename = cookie_path / (name +
"_usr.timestamp");
83 timestamp_filename = cookie_path / (name +
"_dev.timestamp");
87 if (!version_.
empty() &&
90 version = versionMatch.
str(1);
93 server_url =
std::string{
"http://seqan-update.informatik.uni-tuebingen.de/check/SeqAn3_"} +
94 get_os() + get_bit_sys() + name +
"_" + version;
96 program = get_program();
101 command = program +
" " + cookie_path.
string() +
"/" + name +
".version " + server_url;
103 command = command +
"; exit [int] -not $?}\" > nul 2>&1";
105 command = command +
" > /dev/null 2>&1";
143 std::ifstream version_file{cookie_path / (name +
".version")};
145 if (version_file.is_open())
150 if (line != unregistered_app)
151 srv_app_version = get_numbers_from_version_string(line);
155 #endif // !defined(NDEBUG) 158 srv_seqan_version = get_numbers_from_version_string(line);
160 version_file.close();
163 #if !defined(NDEBUG) // only check seqan version in debug 164 if (srv_seqan_version != empty_version)
168 if (seqan_version < srv_seqan_version)
173 if (srv_app_version != empty_version)
175 #if defined(NDEBUG) // only check app version in release 176 if (get_numbers_from_version_string(version) < srv_app_version)
178 #endif // defined(NDEBUG) 180 #if !defined(NDEBUG) // only notify developer that app version should be updated on server 181 if (get_numbers_from_version_string(version) > srv_app_version)
182 std::cerr << message_registered_app_update;
183 #endif // !defined(NDEBUG) 210 tmp_path /=
".config";
221 path dummy = tmp_path /
"dummy.txt";
223 detail::safe_filesystem_entry file_guard{dummy};
225 bool is_open = file.is_open();
226 bool is_good = file.good();
228 file_guard.remove_no_throw();
230 if (!is_good || !is_open)
262 bool decide_if_check_is_performed(
bool developer_approval,
std::optional<bool> user_approval)
264 if (!developer_approval)
267 if (
std::getenv(
"SEQAN3_NO_VERSION_CHECK") !=
nullptr)
271 return user_approval.
value();
279 if (timestamp_file.is_open())
283 if (get_time_diff_to_current(cookie_line) < 86400)
290 if (cookie_line ==
"NEVER")
294 else if (cookie_line ==
"ALWAYS")
300 timestamp_file.close();
308 if (detail::is_terminal())
311 ####################################################################### 312 Automatic Update Notifications 313 ####################################################################### 315 This app can look for updates automatically in the background, 316 do you want to do that? 318 [a] Always perform version checks for this app (the default). 319 [n] Never perform version checks for this app. 320 [y] Yes, perform a version check now, and ask again tomorrow. 321 [s] Skip the version check now, but ask again tomorrow. 323 Please enter one of [a, n, y, s] and press [RETURN]. 325 For more information, see: 326 https://github.com/seqan/seqan3/wiki/Update-Notifications 328 ####################################################################### 359 ####################################################################### 360 Automatic Update Notifications 361 ####################################################################### 362 This app performs automatic checks for updates. For more information 363 see: https://github.com/seqan/seqan3/wiki/Update-Notifications 364 ####################################################################### 375 "[SEQAN3 INFO] :: A new SeqAn3 version is available online.\n" 376 "[SEQAN3 INFO] :: Please visit www.github.com/seqan/seqan3.git for an update\n" 377 "[SEQAN3 INFO] :: or inform the developer of this app.\n" 378 "[SEQAN3 INFO] :: If you don't wish to receive further notifications, set --version-check OFF.\n\n";
381 "[SEQAN3 INFO] :: Thank you for using SeqAn!\n" 382 "[SEQAN3 INFO] :: Do you wish to register your app for update notifications?\n" 383 "[SEQAN3 INFO] :: Just send an email to support@seqan.de with your app name and version number.\n" 384 "[SEQAN3 INFO] :: If you don't wish to receive further notifications, set --version-check OFF.\n\n";
387 "[APP INFO] :: We noticed the app version you use is newer than the one registered with us.\n" 388 "[APP INFO] :: Please send us an email with the new version so we can correct it (support@seqan.de)\n\n";
391 "[APP INFO] :: A new version of this application is now available.\n" 392 "[APP INFO] :: If you don't wish to receive further notifications, set --version-check OFF.\n\n";
402 std::regex version_regex{
"^[[:digit:]]+\\.[[:digit:]]+\\.[[:digit:]]+$"};
417 return "powershell.exe -NoLogo -NonInteractive -Command \"& {Invoke-WebRequest -erroraction 'silentlycontinue' -OutFile";
418 #else // Unix based platforms. 419 if (!
system(
"wget --version > /dev/null 2>&1"))
421 else if (!
system(
"curl --version > /dev/null 2>&1"))
423 #ifndef __linux // ftp call does not work on linux 424 else if (!
system(
"which ftp > /dev/null 2>&1"))
429 #endif // defined(_WIN32) 433 static constexpr
const char * get_os() noexcept
439 #elif defined(_WIN32) 451 static constexpr
const char * get_bit_sys() noexcept
453 #if __x86_64__ || __ppc64__ 461 double get_time_diff_to_current(
std::string const & str_time)
const 464 double curr = co::duration_cast<co::seconds>(co::system_clock::now().time_since_epoch()).
count();
469 return curr - d_time;
493 template <
typename msg_type>
494 void write_cookie(msg_type && msg)
498 auto curr = co::duration_cast<co::seconds>(co::system_clock::now().time_since_epoch()).
count();
502 if (timestamp_file.is_open())
504 timestamp_file << curr <<
'\n' << msg;
505 timestamp_file.close();
#define SEQAN3_VERSION_MINOR
The minor version as MACRO.
Definition: version.hpp:22
T temp_directory_path(T... args)
Provides various utility functions.
std::from_chars_result from_chars(char const *first, char const *last, value_type &value, int base) noexcept
Parse a char sequence into an integral.
Definition: charconv:174
Definition: aligned_sequence_concept.hpp:35
T create_directory(T... args)
T regex_search(T... args)
#define SEQAN3_VERSION_PATCH
The patch version as MACRO.
Definition: version.hpp:24
#define SEQAN3_VERSION_MAJOR
The major version as MACRO.
Definition: version.hpp:20