Create cache directories
This commit is contained in:
parent
f31186add2
commit
a01e591e5f
|
@ -2,6 +2,7 @@ package main
|
|||
|
||||
import (
|
||||
"log"
|
||||
"os"
|
||||
"sevenkeys/database"
|
||||
"sevenkeys/scryfall/methods"
|
||||
)
|
||||
|
@ -19,6 +20,20 @@ func check(err error) {
|
|||
}
|
||||
}
|
||||
|
||||
func createCacheDirectories() error {
|
||||
err := os.Mkdir(CACHE_DIR, os.ModePerm)
|
||||
if err != nil && !os.IsExist(err) {
|
||||
return err
|
||||
}
|
||||
|
||||
err = os.Mkdir(SET_ICON_CACHE_DIR, os.ModePerm)
|
||||
if err != nil && !os.IsExist(err) {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func main() {
|
||||
log.Println("Connecting to database...")
|
||||
db := database.GetDatabaseFromConfig("config.json")
|
||||
|
@ -29,8 +44,10 @@ func main() {
|
|||
check(err)
|
||||
log.Println("Downloaded set data.")
|
||||
|
||||
// Create cache dir
|
||||
// Create icon cache dir
|
||||
log.Println("Creating cache directories...")
|
||||
err = createCacheDirectories()
|
||||
check(err)
|
||||
log.Println("Created cache directories.")
|
||||
|
||||
// Loop through sets, import set data into database and download icons
|
||||
// TODO: Only download icon if we don't already have the file
|
||||
|
|
Loading…
Reference in New Issue