From d047c36dd09b6169bf27c244196e99bb5df54c3a Mon Sep 17 00:00:00 2001 From: Mitchell Date: Sat, 20 Mar 2021 01:37:03 -0400 Subject: Update documentation. Remove all traces of chdir from the steam library. Remove most linter complaints. --- cmd/web/app.go | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'cmd/web/app.go') diff --git a/cmd/web/app.go b/cmd/web/app.go index b0749b5..1050343 100644 --- a/cmd/web/app.go +++ b/cmd/web/app.go @@ -8,11 +8,13 @@ import ( "riedstra.dev/mitch/steam-export/steam" ) +// steamLib is a steam libary with an embeded mutex to protect it type steamLib struct { steam.Library sync.Mutex } +// statusInfo represents the internal status of game installation type statusInfo struct { sync.RWMutex Running bool @@ -23,6 +25,8 @@ type statusInfo struct { Start *time.Time } +// App binds together the steam library, templates, and channel for install +// requests as well as most the app specific http handlers. type App struct { Library *steamLib Status *statusInfo @@ -33,6 +37,8 @@ type App struct { download chan string } +// NewApp sets up the steam library for us as well as parses the embedded +// template func NewApp(libPath string) (*App, error) { lib, err := steam.NewLibrary(libPath) if err != nil { @@ -52,6 +58,9 @@ func NewApp(libPath string) (*App, error) { return a, nil } +// LibrarySet takes care of locking the Library and switching over to a new +// path, unlocking when done. +// Errors will be logged and no changes will be made if unsuccessful. func (a *App) LibrarySet(path string) { Logger.Println("Starting library reload") a.Library.Lock() @@ -66,6 +75,8 @@ func (a *App) LibrarySet(path string) { Logger.Println("Done reloading lib") } +// LibraryReload calls LibrarySet but with the current directory, forcing a reload of +// information off of disk. func (a *App) LibraryReload() { cur := a.Library.Folder a.LibrarySet(cur) -- cgit v1.2.3