46 if (system(command.
c_str()))
95 if (!version_.
empty() &&
137 if (version_file.is_open())
152 version_file.close();
156 if (srv_seqan_version != empty_version)
160 if (seqan_version < srv_seqan_version)
165 if (srv_app_version != empty_version)
196 std::string{
"http://seqan-update.informatik.uni-tuebingen.de/check/SeqAn3_"} +
201 #elif defined(_WIN32)
210 #if __x86_64__ || __ppc64__
219 "; exit [int] -not $?}\" > nul 2>&1";
236 tmp_path /=
".config";
240 create_directory(tmp_path, err);
246 create_directory(tmp_path, err);
251 tmp_path = temp_directory_path();
254 path dummy = tmp_path /
"dummy.txt";
258 bool is_open = file.is_open();
259 bool is_good = file.good();
261 file_guard.remove_no_throw();
263 if (!is_good || !is_open)
301 if (
std::getenv(
"SEQAN3_NO_VERSION_CHECK") !=
nullptr)
305 return user_approval.
value();
313 if (timestamp_file.is_open())
324 if (cookie_line ==
"NEVER")
328 else if (cookie_line ==
"ALWAYS")
334 timestamp_file.close();
345 #######################################################################
346 Automatic Update Notifications
347 #######################################################################
349 This app can look for updates automatically in the background,
350 do you want to do that?
352 [a] Always perform version checks for this app (the default).
353 [n] Never perform version checks for this app.
354 [y] Yes, perform a version check now, and ask again tomorrow.
355 [s] Skip the version check now, but ask again tomorrow.
357 Please enter one of [a, n, y, s] and press [RETURN].
359 For more information, see:
360 https://github.com/seqan/seqan3/wiki/Update-Notifications
362 #######################################################################
394 #######################################################################
395 Automatic Update Notifications
396 #######################################################################
397 This app performs automatic checks for updates. For more information
398 see: https://github.com/seqan/seqan3/wiki/Update-Notifications
399 #######################################################################
410 "[SEQAN3 INFO] :: A new SeqAn version is available online.\n"
411 "[SEQAN3 INFO] :: Please visit www.github.com/seqan/seqan3.git for an update\n"
412 "[SEQAN3 INFO] :: or inform the developer of this app.\n"
413 "[SEQAN3 INFO] :: If you don't wish to receive further notifications, set --version-check OFF.\n\n";
416 "[SEQAN3 INFO] :: Thank you for using SeqAn!\n"
417 "[SEQAN3 INFO] :: Do you wish to register your app for update notifications?\n"
418 "[SEQAN3 INFO] :: Just send an email to support@seqan.de with your app name and version number.\n"
419 "[SEQAN3 INFO] :: If you don't wish to receive further notifications, set --version-check OFF.\n\n";
422 "[APP INFO] :: We noticed the app version you use is newer than the one registered with us.\n"
423 "[APP INFO] :: Please send us an email with the new version so we can correct it (support@seqan.de)\n\n";
426 "[APP INFO] :: A new version of this application is now available.\n"
427 "[APP INFO] :: If you don't wish to receive further notifications, set --version-check OFF.\n\n";
456 return "powershell.exe -NoLogo -NonInteractive -Command \"& {Invoke-WebRequest -erroraction 'silentlycontinue' -OutFile";
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";
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>
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.
A safe guard to manage a filesystem entry, e.g. a file or a directory.
Definition: safe_filesystem_entry.hpp:38
A functor whose operator() performs the server http request and version checks.
Definition: version_check.hpp:58
static std::string get_program()
Returns the command line call as a std::string of an available program depending on the environment.
Definition: version_check.hpp:425
std::filesystem::path timestamp_filename
The timestamp filename.
Definition: version_check.hpp:421
std::filesystem::path cookie_path
The path to store timestamp and version files (either ~/.config/seqan or the tmp directory).
Definition: version_check.hpp:419
static constexpr char const * home_env_name
The environment name of the home environment used by getenv()
Definition: version_check.hpp:404
static constexpr std::string_view message_registered_app_update
The message directed to the developer if the application is registered but under a lower version.
Definition: version_check.hpp:393
std::regex version_regex
The regex to verify a valid version string.
Definition: version_check.hpp:417
void write_cookie(msg_type &&msg)
Writes a cookie file with a specified message.
Definition: version_check.hpp:480
version_checker & operator=(version_checker const &)=default
Defaulted.
std::string version
The version of the application.
Definition: version_check.hpp:415
double get_time_diff_to_current(std::string const &str_time) const
Reads the timestamp file if possible and returns the time difference to the current time.
Definition: version_check.hpp:447
version_checker(std::string name_, std::string const &version_, std::string const &app_url=std::string{})
Initialises the version_checker with the application name and version.
Definition: version_check.hpp:76
static std::filesystem::path get_path()
Returns a writable path to store timestamp and version files or an empty path if none exists.
Definition: version_check.hpp:229
static constexpr std::string_view unregistered_app
The identification string that may appear in the version file if an app is unregistered.
Definition: version_check.hpp:379
~version_checker()=default
Defaulted.
std::string name
The application name.
Definition: version_check.hpp:413
static constexpr std::string_view message_seqan3_update
The message directed to the developer of the app if a new seqan3 version is available.
Definition: version_check.hpp:381
bool decide_if_check_is_performed(update_notifications developer_approval, std::optional< bool > user_approval)
The central decision whether to perform the version check or not.
Definition: version_check.hpp:296
version_checker(version_checker &&)=default
Defaulted.
static constexpr std::string_view message_unregistered_app
The message directed to the developer of the app if the app is not yet registered with us.
Definition: version_check.hpp:387
version_checker(version_checker const &)=default
Defaulted.
void operator()(std::promise< bool > prom)
Initialises the version_checker with the application name and version.
Definition: version_check.hpp:129
version_checker()=delete
This class has to be initialised with name and version information.
version_checker & operator=(version_checker &&)=default
Defaulted.
std::string message_app_update
The message directed to the user of the app if a new app version is available.
Definition: version_check.hpp:397
std::array< int, 3 > get_numbers_from_version_string(std::string const &str) const
Parses a version string into an array of length 3.
Definition: version_check.hpp:461
auto const move
A view that turns lvalue-references into rvalue-references.
Definition: move.hpp:70
Provides various utility functions.
The internal SeqAn3 namespace.
Definition: aligned_sequence_concept.hpp:29
bool is_terminal()
Check whether we are printing to a terminal.
Definition: terminal.hpp:38
void call_server(std::string const &command, std::promise< bool > prom)
Writes a timestamp file and performs the server call to get the newest version information.
Definition: version_check.hpp:43
update_notifications
Indicates whether application allows automatic update notifications by the seqan3::argument_parser.
Definition: auxiliary.hpp:258
@ off
Automatic update notifications should be disabled.
T regex_search(T... args)
Provides seqan3::detail::safe_filesystem_entry.
Provides std::from_chars and std::to_chars if not defined in the stl <charconv> header.
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