Skip to content
This repository has been archived by the owner on Aug 14, 2024. It is now read-only.

Commit

Permalink
uh
Browse files Browse the repository at this point in the history
  • Loading branch information
hexahigh committed Feb 27, 2024
1 parent b80ddba commit f0f0e85
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions backend/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,33 +48,33 @@ var logger *log.Logger

func main() {
logger = log.New(os.Stdout, "", log.LstdFlags)
logger.Println("Starting")
fmt.Println("Starting")

// Initialize the SQLite database
var err error
switch *dbType {
case "mysql":
db, err = sql.Open("mysql", fmt.Sprintf("%s:%s@tcp(%s)/%s", *dbUser, *dbPass, *dbHost, *dbDb))
if err != nil {
logger.Fatal(err)
log.Fatal(err)
}
db.SetConnMaxLifetime(time.Minute * 3)
db.SetMaxOpenConns(10)
db.SetMaxIdleConns(10)
case "sqlite":
db, err = sql.Open("sqlite3", fmt.Sprintf("file:%s?cache=shared&mode=rwc", *dbFile))
if err != nil {
logger.Fatal(err)
log.Fatal(err)
}
default:
logger.Fatalf("Invalid database type: %s", *dbType)
log.Fatalf("Invalid database type: %s", *dbType)
os.Exit(1)
}
onStart()
initDB()

logger.Println("Started")
logger.Println("Listening on port", *port)
fmt.Println("Started")
fmt.Println("Listening on port", *port)

http.HandleFunc("/exists", handleExists)
http.HandleFunc("/store", handleStore)
Expand Down Expand Up @@ -114,10 +114,10 @@ func onStart() {
for _, file := range files {
if filepath.Ext(file.Name()) != ".zst" && *compress {
// File is not compressed and compression is on, warn the user
logger.Printf("Warning: File %s is not compressed, but compression is enabled. You may want to compress this file.\n", file.Name())
log.Printf("Warning: File %s is not compressed, but compression is enabled. You may want to compress this file.\n", file.Name())
} else if filepath.Ext(file.Name()) == ".zst" && !*compress {
// File is compressed and compression is off, warn the user
logger.Printf("Warning: File %s is compressed, but compression is disabled. You may want to decompress this file.\n", file.Name())
log.Printf("Warning: File %s is compressed, but compression is disabled. You may want to decompress this file.\n", file.Name())
}
}
}
Expand Down Expand Up @@ -158,7 +158,7 @@ func initDB() {
uploaded INTEGER NOT NULL
)`)
if err != nil {
logger.Fatalf("Failed to create table: %v", err)
log.Fatalf("Failed to create table: %v", err)
}
}

Expand Down

0 comments on commit f0f0e85

Please sign in to comment.