Fix jar cache size logging.
Always shows up as 0 for non-incremental syncs, since it's logging the size *prior* to the current sync.
@@ -201,21 +201,31 @@ public class JarCache {
if (!removed.isEmpty()) {
context.output(PrintOutput.log(String.format("Removed %d jars", removed.size())));
}
+ } catch (InterruptedException e) {
+ Thread.currentThread().interrupt();
+ context.setCancelled();
+ } catch (ExecutionException e) {
+ logger.warn("Jar Cache synchronization didn't complete", e);
+ IssueOutput.warn("Jar Cache synchronization didn't complete").submit(context);
+ } finally {
+ // update the in-memory record of which files are cached
+ ImmutableMap<String, File> state = readFileState();
+ logCacheSize(context, state);
+ }
+ }
+
+ private static void logCacheSize(BlazeContext context, ImmutableMap<String, File> cachedFiles) {
+ try {
ImmutableMap<File, Long> cacheFileSizes = FileSizeScanner.readFilesizes(cachedFiles.values());
long total = cacheFileSizes.values().stream().mapToLong(x -> x).sum();
String msg =
String.format("Total Jar Cache size: %d kB (%d files)", total / 1024, cachedFiles.size());
context.output(PrintOutput.log(msg));
-
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
context.setCancelled();
} catch (ExecutionException e) {
- logger.warn("Jar Cache synchronization didn't complete", e);
- IssueOutput.warn("Jar Cache synchronization didn't complete").submit(context);
- } finally {
- // update the in-memory record of which files are cached
- readFileState();
+ // ignore any errors reading file sizes for logging purposes
}
}
