checks sha256 if the dest file is given and exists
extract reusable logic to a function
move module checks to after `module` is defined