mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-20 05:16:01 +00:00
Stop walking SD card libraries on every session start and game launch (#2533)
* Stop searching whole libraries on every game launch and session start The install script search ran over every library whenever any game's manifest changed, and again on each launch. It now runs per game, only when that game's build changes, and a launch that names its scripts does no search at all. A store game's shortcut walked its install folder on every scan instead of reusing the ranking the scan keeps. * Search a library for install scripts after the session has started, not before * fix(session): keep deferred seeding off a running prefix and recheck old folder caches * test(session): bound the held library search in the deferred seeding test * fix(session): search a game again when its install script search failed
This commit is contained in:
1 parent
39a4a1b60c
commit
b5f6122d49
6 files changed
+204
-15
No files matched your search
@@ -56,18 +56,75 @@ libraries="$steam_root"
|
||||
for library in $LIBRARIES; do libraries="$libraries
|
||||
$library"; done
|
||||
libraries=$(printf '%s\n%s\n' "$libraries" "$(sed -n 's/^[[:space:]]*"path"[[:space:]]*"\(.*\)"[[:space:]]*$/\1/p' "$steam_root/steamapps/libraryfolders.vdf" 2>/dev/null)" | awk 'NF && !seen[$0]++')
|
||||
sig=$(while IFS= read -r library; do ls -l --time-style=+%s "$library"/steamapps/appmanifest_*.acf 2>/dev/null; done <<<"$libraries" | cksum)
|
||||
if [ "$(head -n 1 "$cache" 2>/dev/null)" != "$sig" ]; then
|
||||
{
|
||||
printf '%s\n' "$sig"
|
||||
while IFS= read -r library; do
|
||||
[ -d "$library/steamapps/common" ] || continue
|
||||
find "$library/steamapps/common" -mindepth 2 -maxdepth 5 -iname 'installscript*.vdf' \
|
||||
-not -path '*/Steamworks Shared/*' 2>/dev/null
|
||||
done <<<"$libraries" | sort -u
|
||||
} >"$cache.tmp" && mv -f "$cache.tmp" "$cache"
|
||||
games=$(while IFS= read -r library; do
|
||||
library="$library" awk '
|
||||
function flush() { if (dir != "") printf "%s|%s|%s|%s\t%s/steamapps/common/%s\n", file, build, updated, size, ENVIRON["library"], dir }
|
||||
FNR == 1 { flush(); file = FILENAME; dir = build = updated = size = "" }
|
||||
{
|
||||
n = split($0, part, "\"")
|
||||
for (i = 2; i + 2 <= n; i += 2) {
|
||||
name = tolower(part[i])
|
||||
if (name == "installdir" && dir == "") dir = part[i + 2]
|
||||
else if (name == "buildid" && build == "") build = part[i + 2]
|
||||
else if (name == "lastupdated" && updated == "") updated = part[i + 2]
|
||||
else if (name == "sizeondisk" && size == "") size = part[i + 2]
|
||||
else continue
|
||||
i += 2
|
||||
}
|
||||
}
|
||||
END { flush() }
|
||||
' "$library"/steamapps/appmanifest_*.acf 2>/dev/null
|
||||
done <<<"$libraries")
|
||||
legacy=
|
||||
[ -s "$cache" ] && ! grep -q $'\t' "$cache" && legacy=$(tail -n +2 "$cache"; echo .)
|
||||
declare -A scanned=() current=()
|
||||
read_scanned() {
|
||||
scanned=()
|
||||
while IFS=$'\t' read -r key _; do
|
||||
[ -n "$key" ] && scanned[$key]=1
|
||||
done < <(grep $'\t' "$cache" 2>/dev/null)
|
||||
}
|
||||
read_scanned
|
||||
later=
|
||||
fresh=()
|
||||
while IFS=$'\t' read -r key dir; do
|
||||
[ -n "$key" ] || continue
|
||||
current[$key]=1
|
||||
[ -z "${scanned[$key]:-}" ] || continue
|
||||
if [ -z "$legacy" ] && [ -n "${DROIDDECK_SEED_SCRIPTS:-}${DROIDDECK_SEED_LATER:-}" ]; then
|
||||
[ -z "${DROIDDECK_SEED_LATER:-}" ] || later=1
|
||||
continue
|
||||
fi
|
||||
[ -d "$dir" ] || continue
|
||||
scanned[$key]=1
|
||||
if [ -n "$legacy" ] && [ "$cache" -nt "${key%%|*}" ]; then
|
||||
found=$(printf '%s\n' "${legacy%.}" | dir="$dir" awk 'index($0, ENVIRON["dir"] "/") == 1')
|
||||
else
|
||||
found=$(find "$dir" -mindepth 1 -maxdepth 4 -iname 'installscript*.vdf' \
|
||||
-not -path '*/Steamworks Shared/*' 2>/dev/null) || continue
|
||||
found=$(printf '%s\n' "$found" | sort -u)
|
||||
fi
|
||||
fresh+=("$key" "$found")
|
||||
done <<<"$games"
|
||||
exec 9>"$cache.lock" && command -v flock >/dev/null 2>&1 && flock 9
|
||||
if [ ${#fresh[@]} -gt 0 ]; then
|
||||
read_scanned
|
||||
for ((i = 0; i < ${#fresh[@]}; i += 2)); do
|
||||
[ -z "${scanned[${fresh[i]}]:-}" ] || continue
|
||||
printf '%s\n' "${fresh[i + 1]}" | key="${fresh[i]}" awk '{ print ENVIRON["key"] "\t" $0 }' >>"$cache"
|
||||
done
|
||||
fi
|
||||
game_scripts() { { tail -n +2 "$cache" 2>/dev/null; printf '%s\n' "${DROIDDECK_SEED_SCRIPTS:-}"; } | sed '/^$/d' | tr '\n' '\0'; }
|
||||
if [ -n "$later" ]; then
|
||||
(DROIDDECK_SEED_LATER= DROIDDECK_SEED_SCRIPTS= DROIDDECK_SEED_DEFERRED=1 setsid "$0" "$steam_root" >/dev/null 2>&1 9>&- &)
|
||||
fi
|
||||
if [ -e "$cache" ]; then
|
||||
keys=$(printf '%s\n' "${!current[@]}") awk -F'\t' '
|
||||
BEGIN { n = split(ENVIRON["keys"], key, "\n"); for (i = 1; i <= n; i++) want[key[i]] = 1 }
|
||||
NF > 1 && ($1 in want)
|
||||
' "$cache" >"$cache.tmp" && { cmp -s "$cache.tmp" "$cache" && rm -f "$cache.tmp" || mv -f "$cache.tmp" "$cache"; }
|
||||
fi
|
||||
[ -z "${DROIDDECK_SEED_DEFERRED:-}" ] || ! pgrep -x wineserver >/dev/null 2>&1 || exit 0
|
||||
game_scripts() { { cut -s -f2- "$cache" 2>/dev/null; printf '%s\n' "${DROIDDECK_SEED_SCRIPTS:-}"; } | sed '/^$/d' | tr '\n' '\0'; }
|
||||
game_pairs=$(game_scripts | read_scripts)
|
||||
[ -n "$(printf '%s' "$game_pairs" | tr -d '[:space:]')" ] && pairs=$(printf '%s\n%s\n' "$pairs" "$game_pairs" | sort -u | sed '/^$/d')
|
||||
declare -A vulkan=()
|
||||
|
||||
@@ -1190,7 +1190,7 @@ case $mode in
|
||||
step "adding the app's own games to the client's library"
|
||||
droiddeck-steam-shortcuts "$steam_root" "$BL_ADDED_GAMES" || true
|
||||
fi
|
||||
droiddeck-seed-redists "$steam_root" || true
|
||||
DROIDDECK_SEED_LATER=1 droiddeck-seed-redists "$steam_root" || true
|
||||
else
|
||||
_bl_x64_tool=$(droiddeck-steam-x64 --default-tool)
|
||||
if [ -n "$_bl_x64_tool" ]; then
|
||||
@@ -1204,7 +1204,7 @@ case $mode in
|
||||
if [ -z "${BL_DESKTOP:-}" ] && [ "${BL_STEAM_UI:-}" != desktop ]; then
|
||||
droiddeck-steam-ui-scale "$steam_root" "${BL_WIDTH:-1280}" "${BL_HEIGHT:-720}" || true
|
||||
fi
|
||||
droiddeck-seed-redists "$steam_root" || true
|
||||
DROIDDECK_SEED_LATER=1 droiddeck-seed-redists "$steam_root" || true
|
||||
fi
|
||||
if [ -n "${BL_SHADER_PRECACHE:-}" ]; then
|
||||
droiddeck-steam-shaders "$BL_SHADER_PRECACHE" "$XDG_DATA_HOME/Steam" \
|
||||
|
||||
Reference in new issue
Block a user