From ee891cd6153f352e71c46f64fc484623151c2880 Mon Sep 17 00:00:00 2001 From: Matthew Faltys Date: Thu, 12 Mar 2020 12:52:49 +0000 Subject: [PATCH] Add parameters for save file caching --- config.gcfg | 2 ++ deps/clean.sh | 7 +++++-- nethack-launcher/cleanup.go | 2 +- nethack-launcher/nethack-launcher.go | 2 ++ 4 files changed, 10 insertions(+), 3 deletions(-) diff --git a/config.gcfg b/config.gcfg index 93382cb..a1bf16e 100644 --- a/config.gcfg +++ b/config.gcfg @@ -6,8 +6,10 @@ nhdatlocation = "/NetHack/dat/nhdat" recoverbinary = "/NetHack/util/recover" sysconflocation = "/NetHack/sys/unix/sysconf" + ttyreccache = "10" sotwversion = "1.1.7" sotwroot = "/sotw" + sotwdumpcache = "5" bootstrapdelay = 1 [redis] diff --git a/deps/clean.sh b/deps/clean.sh index 7c3ed6f..819a389 100755 --- a/deps/clean.sh +++ b/deps/clean.sh @@ -1,12 +1,14 @@ #!/bin/bash HACKDIR=$1 USERDIR=$2 +TTYRECCACHE=$3 +SOTWDUMPCACHE=$4 ### # clean old ttyrecs ### cd /$HACKDIR/user/$USERDIR/ttyrec/ -ls -1tr | head -n -10 | xargs -d '\n' rm -f -- +ls -1tr | head -n -$TTYRECCACHE | xargs -d '\n' rm -f -- ### @@ -16,8 +18,9 @@ cd /$HACKDIR/user/$USERDIR/sotw/ # there are always 4 symlinked files # leave 5 of the latest dumps +DUMPFILES=$(expr $SOTWDUMPCACHE + 4) -FILES=$(ls -1tr *.txt | head -n -9) +FILES=$(ls -1tr *.txt | head -n -$DUMPFILES) for f in $FILES; do #test -h $f || echo "removing old file $f" diff --git a/nethack-launcher/cleanup.go b/nethack-launcher/cleanup.go index 12736f3..e1f81ac 100644 --- a/nethack-launcher/cleanup.go +++ b/nethack-launcher/cleanup.go @@ -11,7 +11,7 @@ func runCleanup(username string) { // non-symlinked .txt files in //user//sotw/ // run cleanup file - out, err := exec.Command("/bin/clean.sh", config.NethackLauncher.HackDir, username).Output() + out, err := exec.Command("/bin/clean.sh", config.NethackLauncher.HackDir, username, config.NethackLauncher.TTYRecCache, config.NethackLauncher.SotwDumpCache).Output() if err != nil { fmt.Println(err) } diff --git a/nethack-launcher/nethack-launcher.go b/nethack-launcher/nethack-launcher.go index 891817f..ac2547e 100644 --- a/nethack-launcher/nethack-launcher.go +++ b/nethack-launcher/nethack-launcher.go @@ -20,8 +20,10 @@ type Config struct { NhdatLocation string RecoverBinary string SysconfLocation string + TTYRecCache string SotwVersion string SotwRoot string + SotwDumpCache string BootstrapDelay time.Duration }