MCPcopy Create free account
hub / github.com/bazelbuild/bazel / main

Method main

src/tools/diskcache/Gc.java:81–115  ·  view source on GitHub ↗
(String[] args)

Source from the content-addressed store, hash-verified

79 new ThreadFactoryBuilder().setNameFormat("disk-cache-gc-%d").build());
80
81 public static void main(String[] args) throws Exception {
82 OptionsParser op = OptionsParser.builder().optionsClasses(Options.class).build();
83 op.parseAndExitUponError(args);
84
85 Options options = op.getOptions(Options.class);
86
87 if (options.diskCache == null) {
88 System.err.println("--disk_cache must be specified.");
89 System.exit(1);
90 }
91
92 if (options.maxSize <= 0 && options.maxAge.isZero()) {
93 System.err.println(
94 "At least one of --max_size or --max_age must be set to a positive value.");
95 System.exit(1);
96 }
97
98 var root = getFileSystem().getPath(options.diskCache);
99 if (!root.isDirectory()) {
100 System.err.println("Expected --disk_cache to exist and be a directory.");
101 System.exit(1);
102 }
103
104 var policy =
105 new CollectionPolicy(
106 options.maxSize == 0 ? Optional.empty() : Optional.of(options.maxSize),
107 options.maxAge.isZero() ? Optional.empty() : Optional.of(options.maxAge));
108
109 var gc = new DiskCacheGarbageCollector(root, executorService, policy);
110
111 CollectionStats stats = gc.run();
112
113 System.out.println(stats.displayString());
114 System.exit(0);
115 }
116
117 private static FileSystem getFileSystem() {
118 // Note: the digest function is irrelevant, as the garbage collector scans the entire disk cache

Callers 1

rewriter_test.pyFile · 0.45

Calls 11

builderMethod · 0.95
parseAndExitUponErrorMethod · 0.95
getOptionsMethod · 0.95
getFileSystemMethod · 0.95
optionsClassesMethod · 0.80
printlnMethod · 0.65
isDirectoryMethod · 0.65
runMethod · 0.65
buildMethod · 0.45
emptyMethod · 0.45
ofMethod · 0.45

Tested by

no test coverage detected