@ -455,7 +455,9 @@ public class GC {
Set < ObjectId > indexObjects = null ;
Set < ObjectId > indexObjects = null ;
File objects = repo . getObjectsDirectory ( ) ;
File objects = repo . getObjectsDirectory ( ) ;
String [ ] fanout = objects . list ( ) ;
String [ ] fanout = objects . list ( ) ;
if ( fanout ! = null & & fanout . length > 0 ) {
if ( fanout = = null | | fanout . length = = 0 ) {
return ;
}
pm . beginTask ( JGitText . get ( ) . pruneLooseUnreferencedObjects ,
pm . beginTask ( JGitText . get ( ) . pruneLooseUnreferencedObjects ,
fanout . length ) ;
fanout . length ) ;
try {
try {
@ -493,9 +495,10 @@ public class GC {
} finally {
} finally {
pm . endTask ( ) ;
pm . endTask ( ) ;
}
}
}
if ( deletionCandidates . isEmpty ( ) )
if ( deletionCandidates . isEmpty ( ) ) {
return ;
return ;
}
checkCancelled ( ) ;
checkCancelled ( ) ;
@ -576,12 +579,19 @@ public class GC {
// loose objects. Make a last check, though, to avoid deleting objects
// loose objects. Make a last check, though, to avoid deleting objects
// that could have been referenced while the candidates list was being
// that could have been referenced while the candidates list was being
// built (by an incoming push, for example).
// built (by an incoming push, for example).
Set < File > touchedFanout = new HashSet < > ( ) ;
for ( File f : deletionCandidates . values ( ) ) {
for ( File f : deletionCandidates . values ( ) ) {
if ( f . lastModified ( ) < expireDate ) {
if ( f . lastModified ( ) < expireDate ) {
f . delete ( ) ;
f . delete ( ) ;
touchedFanout . add ( f . getParentFile ( ) ) ;
}
}
}
}
for ( File f : touchedFanout ) {
FileUtils . delete ( f ,
FileUtils . EMPTY_DIRECTORIES_ONLY | FileUtils . IGNORE_ERRORS ) ;
}
repo . getObjectDatabase ( ) . close ( ) ;
repo . getObjectDatabase ( ) . close ( ) ;
}
}