aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2011-04-13 13:56:02 +0100
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2011-04-15 00:29:38 +0100
commit893010bb06327d80f3cddf2a3f4de496520e74e4 (patch)
treeb616b53281866651392dac131f2ddb2d3f99afc5
parent482e0c9d51e606817af7c25ad68c3ee7314ca95e (diff)
downloadpaludis-893010bb06327d80f3cddf2a3f4de496520e74e4.tar.gz
paludis-893010bb06327d80f3cddf2a3f4de496520e74e4.tar.xz
Don't cache mtimes
-rw-r--r--paludis/repositories/e/e_key.cc51
1 files changed, 28 insertions, 23 deletions
diff --git a/paludis/repositories/e/e_key.cc b/paludis/repositories/e/e_key.cc
index f28c46c..0462087 100644
--- a/paludis/repositories/e/e_key.cc
+++ b/paludis/repositories/e/e_key.cc
@@ -32,7 +32,6 @@
#include <paludis/util/stringify.hh>
#include <paludis/util/tokeniser.hh>
#include <paludis/util/log.hh>
-#include <paludis/util/mutex.hh>
#include <paludis/util/join.hh>
#include <paludis/util/create_iterator-impl.hh>
#include <paludis/util/tribool.hh>
@@ -822,14 +821,37 @@ EContentsKey::type() const
return _imp->type;
}
+namespace
+{
+ Timestamp get_mtime(const FSPath & v)
+ {
+ try
+ {
+ FSStat s(v);
+ if (s.exists())
+ return s.mtim();
+ else
+ {
+ Log::get_instance()->message("e.contents.mtime_failure", ll_warning, lc_context) << "Couldn't get mtime for '"
+ << v << "' because it does not exist";
+ return Timestamp::now();
+ }
+ }
+ catch (const Exception & e)
+ {
+ Log::get_instance()->message("e.contents.mtime_failure", ll_warning, lc_context) << "Couldn't get mtime for '"
+ << v << "' due to exception '" << e.message() << "' (" << e.what() << ")";
+ return Timestamp::now();
+ }
+ }
+}
+
namespace paludis
{
template <>
struct Imp<EMTimeKey>
{
- const FSPath filename;
- mutable Mutex value_mutex;
- mutable std::shared_ptr<Timestamp> value;
+ Timestamp value;
const std::string raw_name;
const std::string human_name;
@@ -837,7 +859,7 @@ namespace paludis
Imp(const FSPath & v,
const std::string & r, const std::string & h, const MetadataKeyType t) :
- filename(v),
+ value(get_mtime(v)),
raw_name(r),
human_name(h),
type(t)
@@ -858,24 +880,7 @@ EMTimeKey::~EMTimeKey()
Timestamp
EMTimeKey::parse_value() const
{
- Lock l(_imp->value_mutex);
-
- if (_imp->value)
- return *_imp->value;
-
- _imp->value = std::make_shared<Timestamp>(Timestamp::now());
-
- try
- {
- *_imp->value = _imp->filename.stat().mtim();
- }
- catch (const FSError & e)
- {
- Log::get_instance()->message("e.contents.mtime_failure", ll_warning, lc_context) << "Couldn't get mtime for '"
- << _imp->filename << "' due to exception '" << e.message() << "' (" << e.what() << ")";
- }
-
- return *_imp->value;
+ return _imp->value;
}
const std::string