]> git.tdb.fi Git - builder.git/commitdiff
Check DataTransform's directory mtime against cache mtime
authorMikko Rasa <tdb@tdb.fi>
Tue, 4 Oct 2016 14:42:18 +0000 (17:42 +0300)
committerMikko Rasa <tdb@tdb.fi>
Tue, 4 Oct 2016 14:42:18 +0000 (17:42 +0300)
Transforms commonly contain wildcard patterns, so the set of source files
may change without the transform itself changing.

source/datatransform.cpp
source/datatransform.h

index e45c80a69085f4e68d51dffc8005476d7ecf206c..2f7e8754b66da94d57eda264608b745f346e8ba3 100644 (file)
@@ -1,4 +1,5 @@
 #include <msp/fs/dir.h>
+#include <msp/fs/stat.h>
 #include <msp/fs/utils.h>
 #include <msp/strings/format.h>
 #include <msp/strings/regex.h>
@@ -16,14 +17,17 @@ DataTransform::DataTransform(Builder &b, const Component &c, const FS::Path &p):
        FileTarget(b, c.get_package(), p)
 {
        component = &c;
+
+       if(FS::Stat st = FS::lstat(FS::dirname(path)))
+               dir_mtime = st.get_modify_time();
 }
 
 void DataTransform::find_dependencies()
 {
        list<string> files;
        Cache &cache = component->get_package().get_cache();
-       // XXX Should check directory mtime as well
-       if(mtime<cache.get_mtime() && cache.has_key(this, "files"))
+       const Time::TimeStamp &cache_mtime = cache.get_mtime();
+       if(mtime<cache_mtime && dir_mtime<cache_mtime && cache.has_key(this, "files"))
                files = cache.get_values(this, "files");
        else
        {
index 38e559bf5e05036c496195d12cc737d1a7436272..b39eacd881ef2e7a32d4d54e7dc99a71b474f8fb 100644 (file)
@@ -5,6 +5,9 @@
 
 class DataTransform: public FileTarget
 {
+private:
+       Msp::Time::TimeStamp dir_mtime;
+
 public:
        DataTransform(Builder &, const Component &, const Msp::FS::Path &);