Add configurable baseURL (required for multi-device support)
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Steven Polley 2023-08-21 19:47:49 -06:00
parent 0b5eb36b5a
commit 5bdda0259a
1 changed files with 7 additions and 2 deletions

View File

@ -39,13 +39,18 @@ const (
cacheFile = "public/romcache.json" // persistence between server restarts so we don't have to rehash all the ROM files each time the program starts
)
var ( // evil global variable
var ( // evil global variables
romCache ROMCache
baseURL string
)
func init() {
// intialize and load ROMCache from file - so we don't have to rehash all the big files again
romCache = ROMCache{}
baseURL = os.Getenv("baseurl")
if len(baseURL) < 1 {
log.Fatalf("required environment variable 'baseurl' is not set.")
}
romCacheJson, err := os.ReadFile(cacheFile)
if err != nil {
@ -140,7 +145,7 @@ func updateROMCache() {
ID: fileHash,
Romtype: splitName[3], // UNOFFICIAL
Size: int(fInfo.Size()),
URL: fmt.Sprintf("https://lineageos-ota.deadbeef.codes/public/%s", v.Name()),
URL: fmt.Sprintf("%s/public/%s", baseURL, v.Name()),
Version: splitName[1],
}