Don't pipe to gunzip
gunzip should not try to seek the stream, but an issue was reported in #407, where it fails with gzip: stdin: unexpected end of file So we're writing to a file first just to be safer. Fixes #407.
This commit is contained in:
parent
dc93d13903
commit
713b7b2f5d
3 changed files with 12 additions and 10 deletions
|
@ -7,7 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||||
|
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
|
|
||||||
_No unreleased changes._
|
### Fixed
|
||||||
|
- gunzip failing with "unexpected end of file" when trying to upgrade zimfw.
|
||||||
|
(See [#407](https://github.com/zimfw/zimfw/issues/407))
|
||||||
|
|
||||||
## [1.3.0] - 2020-07-05
|
## [1.3.0] - 2020-07-05
|
||||||
|
|
||||||
|
|
|
@ -2,22 +2,22 @@ _zimfw_upgrade() {
|
||||||
local -r ztarget=${ZIM_HOME}/zimfw.zsh
|
local -r ztarget=${ZIM_HOME}/zimfw.zsh
|
||||||
local -r zurl=https://github.com/zimfw/zimfw/releases/latest/download/zimfw.zsh.gz
|
local -r zurl=https://github.com/zimfw/zimfw/releases/latest/download/zimfw.zsh.gz
|
||||||
{
|
{
|
||||||
setopt LOCAL_OPTIONS PIPE_FAIL
|
|
||||||
if (( ${+commands[curl]} )); then
|
if (( ${+commands[curl]} )); then
|
||||||
command curl -fsSL ${zurl} | command gunzip > ${ztarget}.new || return 1
|
command curl -fsSL -o ${ztarget}.new.gz ${zurl} || return 1
|
||||||
else
|
else
|
||||||
local zopt
|
local zopt
|
||||||
if (( _zprintlevel <= 1 )) zopt='-q'
|
if (( _zprintlevel <= 1 )) zopt='-q'
|
||||||
if ! command wget -nv ${zopt} -O - ${zurl} | command gunzip > ${ztarget}.new; then
|
if ! command wget -nv ${zopt} -O ${ztarget}.new.gz ${zurl}; then
|
||||||
if (( _zprintlevel <= 1 )) print -u2 -PR "%F{red}<%= error %>Error downloading %B${zurl}%b. Use %B-v%b option to see details.%f"
|
if (( _zprintlevel <= 1 )) print -u2 -PR "%F{red}<%= error %>Error downloading %B${zurl}%b. Use %B-v%b option to see details.%f"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
command gunzip -f ${ztarget}.new.gz || return 1
|
||||||
# .latest_version can be outdated and will yield a false warning if zimfw is
|
# .latest_version can be outdated and will yield a false warning if zimfw is
|
||||||
# upgraded before .latest_version is refreshed. Bad thing about having a cache.
|
# upgraded before .latest_version is refreshed. Bad thing about having a cache.
|
||||||
_zimfw_mv ${ztarget}{.new,} && command rm -f ${ZIM_HOME}/.latest_version && \
|
_zimfw_mv ${ztarget}{.new,} && command rm -f ${ZIM_HOME}/.latest_version && \
|
||||||
_zimfw_print -P '<%= done %>Done with upgrade.'
|
_zimfw_print -P '<%= done %>Done with upgrade.'
|
||||||
} always {
|
} always {
|
||||||
command rm -f ${ztarget}.new
|
command rm -f ${ztarget}.new{,.gz}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
10
zimfw.zsh
10
zimfw.zsh
|
@ -313,7 +313,7 @@ _zimfw_compile() {
|
||||||
}
|
}
|
||||||
|
|
||||||
_zimfw_info() {
|
_zimfw_info() {
|
||||||
print -R 'zimfw version: '${_zversion}' (previous commit is 1e4d1e7)'
|
print -R 'zimfw version: '${_zversion}' (previous commit is dc93d13)'
|
||||||
print -R 'ZIM_HOME: '${ZIM_HOME}
|
print -R 'ZIM_HOME: '${ZIM_HOME}
|
||||||
print -R 'Zsh version: '${ZSH_VERSION}
|
print -R 'Zsh version: '${ZSH_VERSION}
|
||||||
print -R 'System info: '$(command uname -a)
|
print -R 'System info: '$(command uname -a)
|
||||||
|
@ -336,23 +336,23 @@ _zimfw_upgrade() {
|
||||||
local -r ztarget=${ZIM_HOME}/zimfw.zsh
|
local -r ztarget=${ZIM_HOME}/zimfw.zsh
|
||||||
local -r zurl=https://github.com/zimfw/zimfw/releases/latest/download/zimfw.zsh.gz
|
local -r zurl=https://github.com/zimfw/zimfw/releases/latest/download/zimfw.zsh.gz
|
||||||
{
|
{
|
||||||
setopt LOCAL_OPTIONS PIPE_FAIL
|
|
||||||
if (( ${+commands[curl]} )); then
|
if (( ${+commands[curl]} )); then
|
||||||
command curl -fsSL ${zurl} | command gunzip > ${ztarget}.new || return 1
|
command curl -fsSL -o ${ztarget}.new.gz ${zurl} || return 1
|
||||||
else
|
else
|
||||||
local zopt
|
local zopt
|
||||||
if (( _zprintlevel <= 1 )) zopt='-q'
|
if (( _zprintlevel <= 1 )) zopt='-q'
|
||||||
if ! command wget -nv ${zopt} -O - ${zurl} | command gunzip > ${ztarget}.new; then
|
if ! command wget -nv ${zopt} -O ${ztarget}.new.gz ${zurl}; then
|
||||||
if (( _zprintlevel <= 1 )) print -u2 -PR "%F{red}x Error downloading %B${zurl}%b. Use %B-v%b option to see details.%f"
|
if (( _zprintlevel <= 1 )) print -u2 -PR "%F{red}x Error downloading %B${zurl}%b. Use %B-v%b option to see details.%f"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
command gunzip -f ${ztarget}.new.gz || return 1
|
||||||
# .latest_version can be outdated and will yield a false warning if zimfw is
|
# .latest_version can be outdated and will yield a false warning if zimfw is
|
||||||
# upgraded before .latest_version is refreshed. Bad thing about having a cache.
|
# upgraded before .latest_version is refreshed. Bad thing about having a cache.
|
||||||
_zimfw_mv ${ztarget}{.new,} && command rm -f ${ZIM_HOME}/.latest_version && \
|
_zimfw_mv ${ztarget}{.new,} && command rm -f ${ZIM_HOME}/.latest_version && \
|
||||||
_zimfw_print -P 'Done with upgrade.'
|
_zimfw_print -P 'Done with upgrade.'
|
||||||
} always {
|
} always {
|
||||||
command rm -f ${ztarget}.new
|
command rm -f ${ztarget}.new{,.gz}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue