From a40db37e1e681d397d4bfc6c893e15945c533b72 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Mon, 21 Sep 2009 16:23:33 +0000 Subject: [PATCH] Also use file size to determine whether to reinstall a file --- source/filetarget.cpp | 6 +++++- source/filetarget.h | 2 ++ source/install.cpp | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/source/filetarget.cpp b/source/filetarget.cpp index ed3e66b..08b0f31 100644 --- a/source/filetarget.cpp +++ b/source/filetarget.cpp @@ -15,9 +15,13 @@ using namespace Msp; FileTarget::FileTarget(Builder &b, const Package *p, const FS::Path &a): // XXX Builder depends on target name being its path for locating file targets Target(b, p, /*FS::basename*/(a.str())), - path(a) + path(a), + size(0) { struct stat st; if(!FS::stat(path, st)) + { mtime=Time::TimeStamp::from_unixtime(st.st_mtime); + size=st.st_size; + } } diff --git a/source/filetarget.h b/source/filetarget.h index 3b8bfcc..982b8cb 100644 --- a/source/filetarget.h +++ b/source/filetarget.h @@ -19,10 +19,12 @@ class FileTarget: public Target { protected: Msp::FS::Path path; + unsigned size; FileTarget(Builder &, const Package *, const Msp::FS::Path &); public: const Msp::FS::Path &get_path() const { return path; } + unsigned get_size() const { return size; } }; #endif diff --git a/source/install.cpp b/source/install.cpp index b5d70f4..27bb9a3 100644 --- a/source/install.cpp +++ b/source/install.cpp @@ -32,7 +32,7 @@ void Install::check_rebuild() { if(!mtime) mark_rebuild("Does not exist"); - else if(source.get_mtime()>mtime) + else if(source.get_mtime()>mtime || source.get_size()!=size) mark_rebuild(FS::basename(source.get_name())+" has changed"); else if(source.get_rebuild()) mark_rebuild(FS::basename(source.get_name())+" needs rebuilding"); -- 2.45.2