Merge "Check stats dir instead of making one" into main

This commit is contained in:
Junyu Lai 2024-01-19 02:31:50 +00:00 • committed by Gerrit Code Review
commit 91694abf58

View file

@ -109,7 +109,7 @@ public class NetworkStatsMetricsLogger {
*/
private static Pair<Integer, Integer> getStatsFilesAttributes(
@Nullable File statsDir, @NonNull String prefix) {
if (statsDir == null) return new Pair<>(0, 0);
if (statsDir == null || !statsDir.isDirectory()) return new Pair<>(0, 0);
// Only counts the matching files.
// The files are named in the following format:
@ -118,9 +118,6 @@ public class NetworkStatsMetricsLogger {
// See FileRotator#FileInfo for more detail.
final Pattern pattern = Pattern.compile("^" + prefix + "\\.[0-9]+-[0-9]*$");
// Ensure that base path exists.
statsDir.mkdirs();
int totalFiles = 0;
int totalBytes = 0;
for (String name : emptyIfNull(statsDir.list())) {