Class GcLog
- java.lang.Object
-
- org.eclipse.jgit.internal.storage.file.GcLog
-
class GcLog extends java.lang.Object
This class manages the gc.log file for aFileRepository
.
-
-
Field Summary
Fields Modifier and Type Field Description private java.time.Instant
gcLogExpire
private LockFile
lock
private static java.lang.String
LOG_EXPIRY_DEFAULT
private java.io.File
logFile
private boolean
nonEmpty
private FileRepository
repo
-
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 boolean
autoGcBlockedByOldLockFile()
(package private) boolean
commit()
Commit changes to the gc log, if there have been any writes.private java.time.Instant
getLogExpiry()
(package private) boolean
lock()
Lock the GC log file for updates(package private) void
unlock()
Unlock (roll back) the GC log lock(package private) void
write(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:
true
if 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.IOException
Write to the pending gc log. Content will be committed upon a call to commit()- Parameters:
content
- The content to write- Throws:
java.io.IOException
-
-