diff options
author | Marius Kintel <marius@kintel.net> | 2012-07-15 01:57:41 (GMT) |
---|---|---|
committer | Marius Kintel <marius@kintel.net> | 2012-07-15 01:57:41 (GMT) |
commit | 2495df6bab07f14f0eed7062dec17d24599aa838 (patch) | |
tree | 738002af91eb84dc98e20b42520745161be0ca29 /src | |
parent | 3085bcc65cd80cc70b3b118b89ee5a41e7ef8ceb (diff) |
Add timestamp to cache key for modules importing files. Fixes #141
Diffstat (limited to 'src')
-rw-r--r-- | src/import.cc | 9 | ||||
-rw-r--r-- | src/linearextrude.cc | 11 | ||||
-rw-r--r-- | src/rotateextrude.cc | 11 | ||||
-rw-r--r-- | src/surface.cc | 11 |
4 files changed, 38 insertions, 4 deletions
diff --git a/src/import.cc b/src/import.cc index 221ee55..9d011b0 100644 --- a/src/import.cc +++ b/src/import.cc @@ -237,6 +237,7 @@ PolySet *ImportNode::evaluate_polyset(class PolySetEvaluator *) const std::string ImportNode::toString() const { std::stringstream stream; + fs::path path(this->filename); stream << this->name(); stream << "(file = " << this->filename << ", " @@ -244,7 +245,13 @@ std::string ImportNode::toString() const "origin = [" << std::dec << this->origin_x << ", " << this->origin_y << "], " "scale = " << this->scale << ", " "convexity = " << this->convexity << ", " - "$fn = " << this->fn << ", $fa = " << this->fa << ", $fs = " << this->fs << ")"; + "$fn = " << this->fn << ", $fa = " << this->fa << ", $fs = " << this->fs +#ifndef OPENSCAD_TESTING + // timestamp is needed for caching, but disturbs the test framework + << ", " "timestamp = " << (fs::exists(path) ? fs::last_write_time(path) : 0) +#endif + << ")"; + return stream.str(); } diff --git a/src/linearextrude.cc b/src/linearextrude.cc index 89098da..4d2730c 100644 --- a/src/linearextrude.cc +++ b/src/linearextrude.cc @@ -38,6 +38,9 @@ #include <boost/assign/std/vector.hpp> using namespace boost::assign; // bring 'operator+=()' into scope +#include <boost/filesystem.hpp> +namespace fs = boost::filesystem; + class LinearExtrudeModule : public AbstractModule { public: @@ -143,11 +146,17 @@ std::string LinearExtrudeNode::toString() const stream << this->name() << "("; if (!this->filename.empty()) { // Ignore deprecated parameters if empty + fs::path path(this->filename); stream << "file = " << this->filename << ", " "layer = " << QuotedString(this->layername) << ", " "origin = [" << this->origin_x << ", " << this->origin_y << "], " - "scale = " << this->scale << ", "; + "scale = " << this->scale << ", " +#ifndef OPENSCAD_TESTING + // timestamp is needed for caching, but disturbs the test framework + << "timestamp = " << (fs::exists(path) ? fs::last_write_time(path) : 0) << ", " +#endif + ; } stream << "height = " << std::dec << this->height << ", " diff --git a/src/rotateextrude.cc b/src/rotateextrude.cc index 10a8ef9..165d03b 100644 --- a/src/rotateextrude.cc +++ b/src/rotateextrude.cc @@ -38,6 +38,9 @@ #include <boost/assign/std/vector.hpp> using namespace boost::assign; // bring 'operator+=()' into scope +#include <boost/filesystem.hpp> +namespace fs = boost::filesystem; + class RotateExtrudeModule : public AbstractModule { public: @@ -112,11 +115,17 @@ std::string RotateExtrudeNode::toString() const stream << this->name() << "("; if (!this->filename.empty()) { // Ignore deprecated parameters if empty + fs::path path(this->filename); stream << "file = " << this->filename << ", " "layer = " << QuotedString(this->layername) << ", " "origin = [" << std::dec << this->origin_x << ", " << this->origin_y << "], " - "scale = " << this->scale << ", "; + "scale = " << this->scale << ", " +#ifndef OPENSCAD_TESTING + // timestamp is needed for caching, but disturbs the test framework + << "timestamp = " << (fs::exists(path) ? fs::last_write_time(path) : 0) << ", " +#endif + ; } stream << "convexity = " << this->convexity << ", " diff --git a/src/surface.cc b/src/surface.cc index 756ad74..d962e38 100644 --- a/src/surface.cc +++ b/src/surface.cc @@ -43,6 +43,9 @@ #include <boost/assign/std/vector.hpp> using namespace boost::assign; // bring 'operator+=()' into scope +#include <boost/filesystem.hpp> +namespace fs = boost::filesystem; + class SurfaceModule : public AbstractModule { public: @@ -222,9 +225,15 @@ PolySet *SurfaceNode::evaluate_polyset(class PolySetEvaluator *) const std::string SurfaceNode::toString() const { std::stringstream stream; + fs::path path(this->filename); stream << this->name() << "(file = " << this->filename << ", " - "center = " << (this->center ? "true" : "false") << ")"; + "center = " << (this->center ? "true" : "false") +#ifndef OPENSCAD_TESTING + // timestamp is needed for caching, but disturbs the test framework + << ", " "timestamp = " << (fs::exists(path) ? fs::last_write_time(path) : 0) +#endif + << ")"; return stream.str(); } |