mirror of
https://github.com/internetarchive/heritrix3.git
synced 2026-09-26 23:55:50 +00:00
[HER-1546] Springify(5): Update checkpointing to work smoothly with spring-configured crawls
* Checkpoint.java
(generateFrom) version more suitable for unit testing
This commit is contained in:
@@ -79,10 +79,21 @@ public class Checkpoint implements InitializingBean {
|
||||
* @param checkpointsDir
|
||||
*/
|
||||
public void generateFrom(CheckpointService checkpointer) {
|
||||
getCheckpointDir().setBase(checkpointer.getCheckpointsDir());
|
||||
setCheckpointService(checkpointer);
|
||||
generateFrom(checkpointer.getCheckpointsDir(),checkpointer.getNextCheckpointNumber());
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate without CheckpointService (useful for unit testing)
|
||||
*
|
||||
* @param checkpointsDir
|
||||
* @param nextCheckpointNumber
|
||||
*/
|
||||
public void generateFrom(ConfigPath checkpointsDir, int nextCheckpointNumber) {
|
||||
getCheckpointDir().setBase(checkpointsDir);
|
||||
getCheckpointDir().setPath(
|
||||
"cp"
|
||||
+ CheckpointService.INDEX_FORMAT.format(checkpointer.getNextCheckpointNumber())
|
||||
+ CheckpointService.INDEX_FORMAT.format(nextCheckpointNumber)
|
||||
+ "-"
|
||||
+ ArchiveUtils.get14DigitDate());
|
||||
getCheckpointDir().getFile().mkdirs();
|
||||
@@ -90,7 +101,7 @@ public class Checkpoint implements InitializingBean {
|
||||
}
|
||||
|
||||
public void afterPropertiesSet() {
|
||||
if(checkpointDir.getBase()==null) {
|
||||
if(checkpointDir.getBase()==null && checkpointService != null) {
|
||||
// if not otherwise set, adopt base from Checkpointer
|
||||
checkpointDir.setBase(checkpointService.getCheckpointsDir());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user