Fixed database extension

This commit is contained in:
Daniel Legt 2024-01-21 15:27:42 +02:00
parent c0f1ed6879
commit eb94ce4552
4 changed files with 4 additions and 3 deletions

1
.gitignore vendored
View File

@ -2,3 +2,4 @@ snapshots.dat
.env .env
dist dist
data.db data.db
data.sqlite

View File

@ -24,7 +24,7 @@ func GetConfiguration() DHConfig {
config := DHConfig{ config := DHConfig{
DiskFetchFrequency: 5, // default value DiskFetchFrequency: 5, // default value
MaxHistoryAge: 2592000, // default value MaxHistoryAge: 2592000, // default value
DatabaseFilePath: "./data.db", DatabaseFilePath: "./data.sqlite",
Listen: ":8080", Listen: ":8080",
} }

View File

@ -64,7 +64,7 @@ func GetSystemHardDrives(db *gorm.DB, olderThan *time.Time, newerThan *time.Time
for _, sysHDD := range systemHardDrives { for _, sysHDD := range systemHardDrives {
var existingHD HardDrive var existingHD HardDrive
q := db.Where("serial = ?", sysHDD.Serial) q := db.Where("serial = ? AND model = ? AND type = ?", sysHDD.Serial, sysHDD.Model, sysHDD.Type)
if newerThan != nil && olderThan != nil { if newerThan != nil && olderThan != nil {
fmt.Printf("\nNewer Than: %s\n", newerThan) fmt.Printf("\nNewer Than: %s\n", newerThan)

View File

@ -16,7 +16,7 @@ func InitDB() {
var err error var err error
dbPath := config.GetConfiguration().DatabaseFilePath dbPath := config.GetConfiguration().DatabaseFilePath
if dbPath == "" { if dbPath == "" {
dbPath = "./data.db" dbPath = "./data.sqlite"
} }
db, err = gorm.Open(sqlite.Open(dbPath), &gorm.Config{}) db, err = gorm.Open(sqlite.Open(dbPath), &gorm.Config{})