222 if( aStaleTimeoutSec <= 0 )
226 wxFileName lockPath( histPath, wxS(
".repo.lock" ) );
228 if( !lockPath.FileExists() )
232 if( !lockPath.GetTimes(
nullptr, &modTime,
nullptr ) )
235 wxDateTime now = wxDateTime::Now();
236 wxTimeSpan age = now - modTime;
239 (
int)age.GetSeconds().ToLong(), aStaleTimeoutSec );
241 return age.GetSeconds().ToLong() > aStaleTimeoutSec;
248 wxFileName lockPath( histPath, wxS(
".repo.lock" ) );
250 if( !lockPath.FileExists() )
254 wxFileName lockFilePath( histPath, wxS(
".repo" ) );
260 if( lockPath.FileExists() )
262 result = wxRemoveFile( lockPath.GetFullPath() );
266 wxLogError(
"Failed to remove stale lock: %s", lockPath.GetFullPath() );
269 if( lockFilePath.FileExists() )
271 bool lockFileResult = wxRemoveFile( lockFilePath.GetFullPath() );
273 wxLogTrace(
HISTORY_LOCK_TRACE,
"Removed stale lockfile: %s", lockFilePath.GetFullPath() );
wxString GetLockHolder() const
Get information about who currently holds the lock.
HISTORY_LOCK_MANAGER(const wxString &aProjectPath, int aStaleTimeoutSec=0)
Construct a lock manager and attempt to acquire locks.
~HISTORY_LOCK_MANAGER()
Destructor releases all locks and closes git repository.
wxString GetLockError() const
Get error message describing why lock could not be acquired.
static bool BreakStaleLock(const wxString &aProjectPath)
Forcibly remove a stale lock file.
std::unique_ptr< LOCKFILE > m_fileLock
static bool IsLockStale(const wxString &aProjectPath, int aStaleTimeoutSec=0)
Check if a lock file exists and is stale (older than timeout).
bool IsLocked() const
Check if locks were successfully acquired.
static wxString historyPath(const wxString &aProjectPath)
#define HISTORY_LOCK_TRACE
wxString result
Test unit parsing edge cases and error handling.