Skip to content

Commit 2087b06

Browse files
committed
Some more logging
1 parent 968e5ec commit 2087b06

2 files changed

Lines changed: 21 additions & 13 deletions

File tree

src/main/java/edu/harvard/mcz/imagecapture/jobs/AbstractFileScanJob.java

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ static void logMismatch(ScanCounterInterface counter, String filename,
5454
.getProperty(ImageCaptureProperties.KEY_REDUNDANT_COMMENT_BARCODE)
5555
.equals("true")) {
5656
// If so configured, or if image metadata contains a barcode that doesn't
57-
// match the barcode in the image report on barcode/comment missmatch as
57+
// match the barcode in the image report on barcode/comment mismatch as
5858
// an error condition.
5959
try {
6060
RunnableJobError error = new RunnableJobError(
@@ -71,8 +71,7 @@ static void logMismatch(ScanCounterInterface counter, String filename,
7171
// This would normally the case where the image metadata doesn't contain a
7272
// barcode but the image does, and reporting of this state as an error has
7373
// been turned off.
74-
log.debug("Barcode/Comment mismatch: [" + barcode + "]!=[" + exifComment +
75-
"]");
74+
log.debug("Barcode/Comment mismatch: [{}]!=[{}]", barcode, exifComment);
7675
}
7776
}
7877

@@ -387,7 +386,14 @@ protected static void checkFile(File containedFile,
387386
null, null, null, RunnableJobError.TYPE_MISMATCH);
388387
}
389388
counter.appendError(error);
390-
counter.incrementFilesFailed();
389+
// If this is an existing file we're trying to update (reattach=true),
390+
// count it as existing, not as a new failure
391+
if (reattach) {
392+
counter.incrementFilesExisting();
393+
log.debug("Existing image record for file {} still has problems, counted as existing", containedFile.getName());
394+
} else {
395+
counter.incrementFilesFailed();
396+
}
391397
return;
392398
}
393399
}

src/main/java/edu/harvard/mcz/imagecapture/jobs/JobAllImageFilesScan.java

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -251,8 +251,10 @@ public void start() {
251251
// walk through directory tree
252252
Singleton.getSingletonInstance().getMainFrame().setStatusMessage(
253253
"Scanning path: " + startPoint.getPath());
254-
Counter counter = new Counter();
255-
AtomicCounter workerCounter = new AtomicCounter();
254+
log.info("Starting preprocess scan of image files in: " +
255+
startPoint.getPath());
256+
Counter counter = new Counter();
257+
AtomicCounter workerCounter = new AtomicCounter();
256258
// count files to scan
257259
countFiles(startPoint, counter);
258260
setPercentComplete(0);
@@ -264,7 +266,7 @@ public void start() {
264266
// Create executor service once for entire scan to prevent premature
265267
// shutdown during recursive directory traversal (fixes issue where only
266268
// a few files were processed when scanning many files)
267-
269+
268270
// Clean up any existing executor service from previous runs
269271
if (executorService != null && !executorService.isTerminated()) {
270272
log.warn("Executor service from previous run still exists, shutting it down");
@@ -276,7 +278,7 @@ public void start() {
276278
Thread.currentThread().interrupt();
277279
}
278280
}
279-
281+
280282
int concurrencyLevel = Integer.parseInt(
281283
Singleton.getSingletonInstance()
282284
.getProperties()
@@ -287,12 +289,12 @@ public void start() {
287289
for (int i = 0; i < locks.length; ++i) {
288290
locks[i] = new ReentrantLock();
289291
}
290-
292+
291293
log.info("Starting file scan with " + concurrencyLevel + " threads, total files to process: " + counter.getTotal());
292294
checkFiles(startPoint, counter, workerCounter);
293-
295+
294296
// Shutdown executor and wait for all tasks to complete
295-
log.info("File scanning completed, shutting down executor and waiting for " +
297+
log.info("File scanning completed, shutting down executor and waiting for " +
296298
workerCounter.getFilesSeen() + " processing tasks to finish");
297299
executorService.shutdown();
298300
try {
@@ -302,7 +304,7 @@ public void start() {
302304
long startWait = System.currentTimeMillis();
303305
if (!executorService.awaitTermination(12, TimeUnit.HOURS)) {
304306
long waitedMinutes = (System.currentTimeMillis() - startWait) / 60000;
305-
log.warn("Execution pool did not terminate within 12 hours (waited " +
307+
log.warn("Execution pool did not terminate within 12 hours (waited " +
306308
waitedMinutes + " minutes), forcing shutdown. " +
307309
"Files processed: " + workerCounter.getFilesSeen() + " of " + counter.getTotal());
308310
executorService.shutdownNow();
@@ -314,7 +316,7 @@ public void start() {
314316
log.info("All processing tasks completed successfully after " + waitedSeconds + " seconds");
315317
}
316318
} catch (InterruptedException e) {
317-
log.error("Execution pool interrupted during termination, processed " +
319+
log.error("Execution pool interrupted during termination, processed " +
318320
workerCounter.getFilesSeen() + " of " + counter.getTotal() + " files", e);
319321
executorService.shutdownNow();
320322
Thread.currentThread().interrupt();

0 commit comments

Comments
 (0)