Skip to content

Commit 210f68d

Browse files
committed
FileFetcher acknowledges suppression of processed files
1 parent 56ab9f6 commit 210f68d

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

‎Common/Utils/src/FileFetcher.cxx‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include "CommonUtils/FileSystemUtils.h"
1818
#include "Framework/Logger.h"
1919
#include <filesystem>
20+
#include <fmt/chrono.h>
2021
#include <fstream>
2122
#include <memory>
2223
#include <thread>
@@ -183,6 +184,7 @@ size_t FileFetcher::popFromQueue(bool discard)
183184
}
184185
auto id = mQueue.front();
185186
mQueue.pop();
187+
LOGP(info, "removing processed {} from the queue, discard flag is {}", mInputFiles[id].getLocalName(), discard);
186188
if (discard) {
187189
discardFile(mInputFiles[id].getLocalName());
188190
}
@@ -234,6 +236,19 @@ void FileFetcher::cleanup()
234236
throw std::runtime_error("FileFetcher thread is still active, cannot cleanup");
235237
}
236238
if (mNRemote && o2::utils::Str::pathExists(mCopyDirName)) {
239+
try {
240+
LOGP(info, "FileFetcher scratch directory {} contents (modification date, size in bytes, name):", mCopyDirName);
241+
for (const auto& entry : fs::directory_iterator(mCopyDirName)) {
242+
const auto fileTime = entry.last_write_time();
243+
const auto systemTime = std::chrono::time_point_cast<std::chrono::system_clock::duration>(
244+
fileTime - fs::file_time_type::clock::now() + std::chrono::system_clock::now());
245+
const auto modificationTime = std::chrono::system_clock::to_time_t(systemTime);
246+
const auto size = entry.is_regular_file() ? std::to_string(entry.file_size()) : "-";
247+
LOGP(info, "{:%Y-%m-%d %H:%M:%S} {} {}", fmt::localtime(modificationTime), size, entry.path().filename().string());
248+
}
249+
} catch (const std::exception& e) {
250+
LOGP(error, "FileFetcher failed to list scratch directory {}: {}", mCopyDirName, e.what());
251+
}
237252
try {
238253
fs::remove_all(mCopyDirName);
239254
} catch (...) {
@@ -319,6 +334,7 @@ void FileFetcher::discardFile(const std::string& fname)
319334
mInputFiles[ent->second - 1].copied = false;
320335
fs::remove(fname);
321336
mCopied.erase(fname);
337+
LOGP(info, "removing processed file {} from the disk", fname);
322338
}
323339
}
324340

0 commit comments

Comments
 (0)