diff options
Diffstat (limited to 'cmd/web/app.go')
| -rw-r--r-- | cmd/web/app.go | 11 |
1 files changed, 11 insertions, 0 deletions
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) |
