add hash only if truncateHash is defined

avoid to have file with undefined hash when truncateHash is not set