32namespace seqan3::detail
66 version_checker() =
delete;
67 version_checker(version_checker
const &) =
default;
68 version_checker & operator=(version_checker
const &) =
default;
69 version_checker(version_checker &&) =
default;
70 version_checker & operator=(version_checker &&) =
default;
71 ~version_checker() =
default;
79 name{std::move(name_)}
85 message_app_update.pop_back();
86 message_app_update.append(
"[APP INFO] :: Visit " + app_url +
" for updates.\n\n");
90 timestamp_filename = cookie_path / (name +
"_usr.timestamp");
92 timestamp_filename = cookie_path / (name +
"_dev.timestamp");
97 if (!version_.
empty() &&
100 version = versionMatch.
str(1);
137 std::ifstream version_file{cookie_path / (name +
".version")};
139 if (version_file.is_open())
144 if (line != unregistered_app)
145 srv_app_version = get_numbers_from_version_string(line);
152 srv_seqan_version = get_numbers_from_version_string(line);
154 version_file.close();
158 if (srv_seqan_version != empty_version)
162 if (seqan_version < srv_seqan_version)
167 if (srv_app_version != empty_version)
170 if (get_numbers_from_version_string(version) < srv_app_version)
175 if (get_numbers_from_version_string(version) > srv_app_version)
176 std::cerr << message_registered_app_update;
195 " " + out_file.
string() +
" "
196 +
std::string{
"http://seqan-update.informatik.uni-tuebingen.de/check/SeqAn3_"} +
210#if __x86_64__ || __ppc64__
218 "; exit [int] -not $?}\" > nul 2>&1";
235 tmp_path /=
".config";
253 path dummy = tmp_path /
"dummy.txt";
255 detail::safe_filesystem_entry file_guard{dummy};
257 bool is_open = file.is_open();
258 bool is_good = file.good();
260 file_guard.remove_no_throw();
262 if (!is_good || !is_open)
300 if (
std::getenv(
"SEQAN3_NO_VERSION_CHECK") !=
nullptr)
304 return user_approval.
value();
312 if (timestamp_file.is_open())
316 if (get_time_diff_to_current(cookie_line) < 86400 )
323 if (cookie_line ==
"NEVER")
327 else if (cookie_line ==
"ALWAYS")
333 timestamp_file.close();
341 if (detail::is_terminal())
344#######################################################################
345 Automatic Update Notifications
346#######################################################################
348 This app can look for updates automatically in the background,
349 do you want to do that?
351 [a] Always perform version checks for this app (the default).
352 [n] Never perform version checks for this app.
353 [y] Yes, perform a version check now, and ask again tomorrow.
354 [s] Skip the version check now, but ask again tomorrow.
356 Please enter one of [a, n, y, s] and press [RETURN].
358 For more information, see:
359 https://github.com/seqan/seqan3/wiki/Update-Notifications
361#######################################################################
393#######################################################################
394 Automatic Update Notifications
395#######################################################################
396 This app performs automatic checks for updates. For more information
397 see: https://github.com/seqan/seqan3/wiki/Update-Notifications
398#######################################################################
409 "[SEQAN3 INFO] :: A new SeqAn version is available online.\n"
410 "[SEQAN3 INFO] :: Please visit www.github.com/seqan/seqan3.git for an update\n"
411 "[SEQAN3 INFO] :: or inform the developer of this app.\n"
412 "[SEQAN3 INFO] :: If you don't wish to receive further notifications, set --version-check false.\n\n";
415 "[SEQAN3 INFO] :: Thank you for using SeqAn!\n"
416 "[SEQAN3 INFO] :: Do you wish to register your app for update notifications?\n"
417 "[SEQAN3 INFO] :: Just send an email to support@seqan.de with your app name and version number.\n"
418 "[SEQAN3 INFO] :: If you don't wish to receive further notifications, set --version-check false.\n\n";
421 "[APP INFO] :: We noticed the app version you use is newer than the one registered with us.\n"
422 "[APP INFO] :: Please send us an email with the new version so we can correct it (support@seqan.de)\n\n";
425 "[APP INFO] :: A new version of this application is now available.\n"
426 "[APP INFO] :: If you don't wish to receive further notifications, set --version-check false.\n\n";
430 static constexpr char const * home_env_name
444 std::regex version_regex{
"^[[:digit:]]+\\.[[:digit:]]+\\.[[:digit:]]+$"};
455 return "powershell.exe -NoLogo -NonInteractive -Command \"& {Invoke-WebRequest -erroraction 'silentlycontinue' "
458 if (!
system(
"/usr/bin/env -i wget --version > /dev/null 2>&1"))
459 return "/usr/bin/env -i wget --timeout=10 --tries=1 -q -O";
460 else if (!
system(
"/usr/bin/env -i curl --version > /dev/null 2>&1"))
461 return "/usr/bin/env -i curl --connect-timeout 10 -o";
464# if defined(__OpenBSD__)
465 return "/usr/bin/env -i ftp -w10 -Vo";
466# elif defined(__FreeBSD__)
467 return "/usr/bin/env -i fetch --timeout=10 -o";
475 double get_time_diff_to_current(
std::string const & str_time)
const
478 double curr = co::duration_cast<co::seconds>(co::system_clock::now().time_since_epoch()).count();
483 return curr - d_time;
507 template <
typename msg_type>
508 void write_cookie(msg_type && msg)
512 auto curr = co::duration_cast<co::seconds>(co::system_clock::now().time_since_epoch()).count();
516 if (timestamp_file.is_open())
518 timestamp_file << curr <<
'\n' << msg;
519 timestamp_file.close();
Provides auxiliary information.
The <charconv> header from C++17's standard library.
T create_directory(T... args)
Provides various utility functions.
update_notifications
Indicates whether application allows automatic update notifications by the seqan3::argument_parser.
Definition: auxiliary.hpp:267
@ off
Automatic update notifications should be disabled.
T regex_search(T... args)
Provides seqan3::detail::safe_filesystem_entry.
T temp_directory_path(T... args)
Checks if program is run interactively and retrieves dimensions of terminal (Transferred from seqan2)...
Provides SeqAn version macros and global variables.
#define SEQAN3_VERSION_MAJOR
The major version as MACRO.
Definition: version.hpp:19
#define SEQAN3_VERSION_PATCH
The patch version as MACRO.
Definition: version.hpp:23
#define SEQAN3_VERSION_MINOR
The minor version as MACRO.
Definition: version.hpp:21