From 981069af8d23c21268f5fde6a82aa40924d77762 Mon Sep 17 00:00:00 2001 From: Jonathan Nguyen Date: Thu, 13 Feb 2020 15:44:10 -0800 Subject: [PATCH] Fix issue where train files would not be deleted past TTL or when over file number limit. Test: manual test Change-Id: Iba6a7f7236cb37dd392ce535ff1875cd31bc9c59 --- cmds/statsd/src/storage/StorageManager.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cmds/statsd/src/storage/StorageManager.cpp b/cmds/statsd/src/storage/StorageManager.cpp index 1bac19ed2c5d7..4899b4a5247c4 100644 --- a/cmds/statsd/src/storage/StorageManager.cpp +++ b/cmds/statsd/src/storage/StorageManager.cpp @@ -690,14 +690,16 @@ void StorageManager::trimToFit(const char* path, bool parseTimestampOnly) { if (name[0] == '.') continue; FileName output; + string file_name; if (parseTimestampOnly) { + file_name = StringPrintf("%s/%s", path, name); output.mTimestampSec = StrToInt64(strtok(name, "_")); output.mIsHistory = false; } else { parseFileName(name, &output); + file_name = output.getFullFileName(path); } if (output.mTimestampSec == -1) continue; - string file_name = output.getFullFileName(path); // Check for timestamp and delete if it's too old. long fileAge = nowSec - output.mTimestampSec;