Add configurable baseURL (required for multi-device support)
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
0b5eb36b5a
commit
5bdda0259a
9
main.go
9
main.go
@ -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
|
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
|
romCache ROMCache
|
||||||
|
baseURL string
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
// intialize and load ROMCache from file - so we don't have to rehash all the big files again
|
// intialize and load ROMCache from file - so we don't have to rehash all the big files again
|
||||||
romCache = ROMCache{}
|
romCache = ROMCache{}
|
||||||
|
baseURL = os.Getenv("baseurl")
|
||||||
|
if len(baseURL) < 1 {
|
||||||
|
log.Fatalf("required environment variable 'baseurl' is not set.")
|
||||||
|
}
|
||||||
|
|
||||||
romCacheJson, err := os.ReadFile(cacheFile)
|
romCacheJson, err := os.ReadFile(cacheFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -140,7 +145,7 @@ func updateROMCache() {
|
|||||||
ID: fileHash,
|
ID: fileHash,
|
||||||
Romtype: splitName[3], // UNOFFICIAL
|
Romtype: splitName[3], // UNOFFICIAL
|
||||||
Size: int(fInfo.Size()),
|
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],
|
Version: splitName[1],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user