diff options
author | Aaron LI <aly@aaronly.me> | 2018-03-10 23:35:20 +0800 |
---|---|---|
committer | Aaron LI <aly@aaronly.me> | 2018-03-10 23:37:49 +0800 |
commit | 5ccc0757901419acc3b2decdac86ac133eb9647c (patch) | |
tree | b1f67c98e81917a9ddc264e19ac8399796b86258 | |
parent | 2586ff0e25596d58307cdbc7ba454f3fa4ea4461 (diff) | |
download | dfly-update-5ccc0757901419acc3b2decdac86ac133eb9647c.tar.bz2 |
checksum_image(): Fix md5 check when given file doesn't exist
-rwxr-xr-x | dfly-update | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/dfly-update b/dfly-update index 68efc99..e4666eb 100755 --- a/dfly-update +++ b/dfly-update @@ -32,6 +32,7 @@ EC_VN=17 EC_TAR=18 EC_MTREE=19 EC_CPDUP=20 +EC_NOFILE=21 # @@ -266,8 +267,9 @@ checksum_image() { local file="$1" local md5_match="$2" local md5 - [ -f "${file}" ] && md5=$(md5 -q "${file}") - if [ -n "${md5}" ] && [ "${md5}" = "${md5_match}" ]; then + [ -f "${file}" ] || error ${EC_NOFILE} "checksum_image: file not exists" + md5=$(md5 -q "${file}") + if [ "${md5}" = "${md5_match}" ]; then return 0 else return 1 |