Add timeout parameter to update_cached_repo().
This commit is contained in:
parent
6cf543a7b4
commit
8f5e9ec7e0
|
@ -48,7 +48,6 @@ using std::runtime_error;
|
|||
using std::string;
|
||||
using std::string_view;
|
||||
using std::to_string;
|
||||
using std::uint64_t;
|
||||
using std::uint8_t;
|
||||
using std::this_thread::sleep_for;
|
||||
|
||||
|
@ -218,10 +217,10 @@ string get_branch_name()
|
|||
return "web-" + to_string(id);
|
||||
}
|
||||
|
||||
void update_cached_repo()
|
||||
void update_cached_repo(const uint8_t timeout)
|
||||
{
|
||||
bool lock_created{false};
|
||||
for (uint8_t counter{0}; counter < 20; ++counter)
|
||||
for (uint8_t counter{0}; counter < timeout; ++counter)
|
||||
{
|
||||
if ((lock_created = files::create_lockfile()))
|
||||
{
|
||||
|
|
12
src/git.hpp
12
src/git.hpp
|
@ -28,7 +28,7 @@ namespace FediBlock::git
|
|||
{
|
||||
|
||||
using std::string;
|
||||
using std::uint64_t;
|
||||
using std::uint8_t;
|
||||
|
||||
/*!
|
||||
* @brief Initialize libgit and _repo_dir.
|
||||
|
@ -75,8 +75,14 @@ void push();
|
|||
// Get the name of the branch we use.
|
||||
string get_branch_name();
|
||||
|
||||
// If cached repo exist, pull. If not, clone.
|
||||
void update_cached_repo();
|
||||
/*!
|
||||
* @brief If cached repo exist, pull --force. If not, clone.
|
||||
*
|
||||
* @param timeout Try to create lockfile for this many seconds. Default is 20.
|
||||
*
|
||||
* @since 0.1.0
|
||||
*/
|
||||
void update_cached_repo(uint8_t timeout = 20);
|
||||
|
||||
} // namespace FediBlock::git
|
||||
|
||||
|
|
Reference in New Issue