Skip to content

Commit 3035ecc

Browse files
committed
fix(prefix): cache Proton tarballs in $CACHE_DIR/proton; fix init prefix-exists check
install_proton: tarballs now saved to $CACHE_DIR/proton/ (~/.cache/wine-installers/proton/) instead of /tmp. Before downloading, the cached file is checked by exact version name — if present the download is skipped entirely. No deletion after extraction so subsequent wig full reuses the archive. gh CLI fallback also saves to the cache directory. init(): changed prefix-exists check from -d $WINEPREFIX (which the full_setup pre-build step creates with mkdir -p) to -d $WINEPREFIX/pfx/drive_c, which only exists once Proton has actually initialised the prefix. Eliminates the confusing 'Prefix already exists — re-running non-destructively' message during wig full.
1 parent 4e8c710 commit 3035ecc

1 file changed

Lines changed: 17 additions & 9 deletions

File tree

lib/prefix.sh

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ restore_launcher_data() {
258258

259259
# Initialise a fresh Wine prefix with all required dependencies.
260260
init() {
261-
if [ -d "${WINEPREFIX:-}" ]; then
261+
if [ -d "${WINEPREFIX:-}/pfx/drive_c" ]; then
262262
print_info "Prefix already exists at $WINEPREFIX — re-running dependencies non-destructively"
263263
print_info "(Use './setup full' to start completely fresh)"
264264
else
@@ -715,16 +715,24 @@ install_proton() {
715715
local _archives=("${version}-${_arch}.tar.gz" "${version}.tar.gz")
716716
mkdir -p "$PROTON_DIR"
717717

718-
local archive=""
718+
# Cache tarballs in $CACHE_DIR/proton so repeated wig full skips the download.
719+
local _pcache="$CACHE_DIR/proton"
720+
mkdir -p "$_pcache"
721+
722+
local archive="" archive_path=""
719723
for _try in "${_archives[@]}"; do
724+
local _cached="$_pcache/${_try}"
725+
if [ -f "$_cached" ]; then
726+
print_info "Using cached Proton tarball: $_try"
727+
archive="$_try"; archive_path="$_cached"; break
728+
fi
720729
local _url="https://github.com/GloriousEggroll/proton-ge-custom/releases/download/${version}/${_try}"
721730
for _attempt in 1 2 3; do
722731
print_info "Downloading ${_try} (attempt ${_attempt}/3)..."
723-
if wget -q --show-progress -O "/tmp/${_try}" "$_url"; then
724-
archive="$_try"
725-
break 2
732+
if wget -q --show-progress -O "$_cached" "$_url"; then
733+
archive="$_try"; archive_path="$_cached"; break 2
726734
fi
727-
rm -f "/tmp/${_try}"
735+
rm -f "$_cached"
728736
[ "$_attempt" -lt 3 ] && sleep $((_attempt * 2))
729737
done
730738
done
@@ -735,8 +743,9 @@ install_proton() {
735743
if gh release download "$version" \
736744
--repo GloriousEggroll/proton-ge-custom \
737745
--pattern "*${_arch}.tar.gz" \
738-
--dir /tmp --clobber 2>/dev/null; then
746+
--dir "$_pcache" --clobber 2>/dev/null; then
739747
archive="${version}-${_arch}.tar.gz"
748+
archive_path="$_pcache/$archive"
740749
fi
741750
fi
742751

@@ -747,8 +756,7 @@ install_proton() {
747756
fi
748757

749758
print_info "Extracting Proton-GE..."
750-
run_without_oas tar -xf "/tmp/${archive}" -C "$PROTON_DIR" --strip-components=1
751-
rm -f "/tmp/${archive}"
759+
run_without_oas tar -xf "$archive_path" -C "$PROTON_DIR" --strip-components=1
752760
print_success "Proton-GE ${version} installed to $PROTON_DIR"
753761
}
754762

0 commit comments

Comments
 (0)