Browse Source

fix(core_dl): fix zip extraction with extractsrc across devices and non-empty dirs

Using mv to move extracted directories fails in two cases:
- Cross-device moves (e.g. tmp and serverfiles on different Docker volumes)
- Target directory already exists and is non-empty (update scenario)

Replace find+mv with cp -a which handles both cases by copying recursively
and merging into the destination. Also replace the hardcoded 'Xonotic'
temp_extractdir with ${extractsrc} to be generic.
pull/4896/head
Daniel Gibbs 2 months ago
parent
commit
83bab98046
Failed to extract signature
  1. 4
      lgsm/modules/core_dl.sh

4
lgsm/modules/core_dl.sh

@ -267,9 +267,9 @@ fn_dl_extract() {
fi
elif [ "${mime}" == "application/zip" ]; then
if [ -n "${extractsrc}" ]; then
temp_extractdir="${tmpdir}/Xonotic"
temp_extractdir="${tmpdir}/${extractsrc}"
extractcmd=$(unzip -qo "${local_filedir}/${local_filename}" "${extractsrc}/*" -d "${temp_extractdir}")
find "${temp_extractdir}/${extractsrc}" -mindepth 1 -maxdepth 1 -exec mv -t "${extractdest}" {} +
cp -a "${temp_extractdir}/${extractsrc}/." "${extractdest}/"
rm -rf "${temp_extractdir}"
else
extractcmd=$(unzip -qo -d "${extractdest}" "${local_filedir}/${local_filename}")

Loading…
Cancel
Save