Class GcLog
- java.lang.Object
-
- org.eclipse.jgit.internal.storage.file.GcLog
-
class GcLog extends java.lang.ObjectThis class manages the gc.log file for aFileRepository.
-
-
Field Summary
Fields Modifier and Type Field Description private java.time.InstantgcLogExpireprivate LockFilelockprivate static java.lang.StringLOG_EXPIRY_DEFAULTprivate java.io.FilelogFileprivate booleannonEmptyprivate FileRepositoryrepo
-
Constructor Summary
Constructors Constructor Description GcLog(FileRepository repo)Construct a GcLog object for aFileRepository
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private booleanautoGcBlockedByOldLockFile()(package private) booleancommit()Commit changes to the gc log, if there have been any writes.private java.time.InstantgetLogExpiry()(package private) booleanlock()Lock the GC log file for updates(package private) voidunlock()Unlock (roll back) the GC log lock(package private) voidwrite(java.lang.String content)Write to the pending gc log.
-
-
-
Field Detail
-
repo
private final FileRepository repo
-
logFile
private final java.io.File logFile
-
lock
private final LockFile lock
-
gcLogExpire
private java.time.Instant gcLogExpire
-
LOG_EXPIRY_DEFAULT
private static final java.lang.String LOG_EXPIRY_DEFAULT
- See Also:
- Constant Field Values
-
nonEmpty
private boolean nonEmpty
-
-
Constructor Detail
-
GcLog
GcLog(FileRepository repo)
Construct a GcLog object for aFileRepository- Parameters:
repo- the repository
-
-
Method Detail
-
getLogExpiry
private java.time.Instant getLogExpiry() throws java.text.ParseException- Throws:
java.text.ParseException
-
autoGcBlockedByOldLockFile
private boolean autoGcBlockedByOldLockFile()
-
lock
boolean lock()
Lock the GC log file for updates- Returns:
trueif we hold the lock
-
unlock
void unlock()
Unlock (roll back) the GC log lock
-
commit
boolean commit()
Commit changes to the gc log, if there have been any writes. Otherwise, just unlock and delete the existing file (if any)- Returns:
- true if committing (or unlocking/deleting) succeeds.
-
write
void write(java.lang.String content) throws java.io.IOExceptionWrite to the pending gc log. Content will be committed upon a call to commit()- Parameters:
content- The content to write- Throws:
java.io.IOException
-
-