2017-12-05 07:57:41 +00:00
|
|
|
#include "timestamp_manager.h"
|
|
|
|
|
2017-12-29 17:27:56 +00:00
|
|
|
#include "cache_manager.h"
|
2017-12-05 07:57:41 +00:00
|
|
|
#include "indexer.h"
|
|
|
|
|
|
|
|
optional<int64_t> TimestampManager::GetLastCachedModificationTime(
|
2017-12-29 17:27:56 +00:00
|
|
|
ICacheManager* cache_manager,
|
2017-12-05 07:57:41 +00:00
|
|
|
const std::string& path) {
|
|
|
|
{
|
|
|
|
std::lock_guard<std::mutex> guard(mutex_);
|
|
|
|
auto it = timestamps_.find(path);
|
|
|
|
if (it != timestamps_.end())
|
|
|
|
return it->second;
|
|
|
|
}
|
2017-12-29 17:27:56 +00:00
|
|
|
IndexFile* file = cache_manager->TryLoad(path);
|
2017-12-05 07:57:41 +00:00
|
|
|
if (!file)
|
|
|
|
return nullopt;
|
|
|
|
|
|
|
|
UpdateCachedModificationTime(path, file->last_modification_time);
|
|
|
|
return file->last_modification_time;
|
|
|
|
}
|
|
|
|
|
|
|
|
void TimestampManager::UpdateCachedModificationTime(const std::string& path,
|
|
|
|
int64_t timestamp) {
|
|
|
|
std::lock_guard<std::mutex> guard(mutex_);
|
|
|
|
timestamps_[path] = timestamp;
|
|
|
|
}
|