When hashes are on, use SHA1 hashes to decide if a file needs to be updated.  The hash is now computed from the hashes of its input files instead of from the output file contents, which means it only changes when the input files change.  When trying to decide whether to update a file we can check whether its computed filename differs from its previously saved filename in the json file.
Fix a bug where files were being built twice if hashes are on; it first rebuilt it because an input changed, then rebuilt it again because it thought an output file was missing.  This adds a missing piece of code to throw away the old list of outputs when returning False from is_fresh().