220 if( aStaleTimeoutSec <= 0 )
224 wxFileName lockPath( histPath, wxS(
".repo.lock" ) );
226 if( !lockPath.FileExists() )
230 if( !lockPath.GetTimes(
nullptr, &modTime,
nullptr ) )
233 wxDateTime now = wxDateTime::Now();
234 wxTimeSpan age = now - modTime;
237 (
int)age.GetSeconds().ToLong(), aStaleTimeoutSec );
239 return age.GetSeconds().ToLong() > aStaleTimeoutSec;
246 wxFileName lockPath( histPath, wxS(
".repo.lock" ) );
248 if( !lockPath.FileExists() )
252 wxFileName lockFilePath( histPath, wxS(
".repo" ) );
258 if( lockPath.FileExists() )
260 result = wxRemoveFile( lockPath.GetFullPath() );
264 wxLogError(
"Failed to remove stale lock: %s", lockPath.GetFullPath() );
267 if( lockFilePath.FileExists() )
269 bool lockFileResult = wxRemoveFile( lockFilePath.GetFullPath() );
271 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.