Skip to content

Commit

Permalink
feat: add log messages
Browse files Browse the repository at this point in the history
  • Loading branch information
fritterhoff committed Sep 21, 2023
1 parent f5e9b7a commit 4d86334
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions offline.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,16 +118,19 @@ func NewOfflineDatabase(dbFile string, updatedDbFile string) (*OfflineDatabase,

if _, err := os.Stat(updatedDbFile); err == nil {
if !lockExists {
logger.Info("Updating database")
if err := os.Rename(updatedDbFile, dbFile); err != nil {
return nil, fmt.Errorf("error moving updated database: %s", err)
}
logger.Info("Database updated")
}
}

db, err := mmap.Open(dbFile)
if err != nil {
return nil, fmt.Errorf("error opening index: %s", err)
}
logger.Info("Database opened")
c := cron.New()
odb := &OfflineDatabase{
database: db,
Expand All @@ -142,6 +145,7 @@ func NewOfflineDatabase(dbFile string, updatedDbFile string) (*OfflineDatabase,
lockExists = true
}
if !lockExists {
logger.Info("Updating database")
db.Close()
if err := os.Rename(updatedDbFile, dbFile); err != nil {
log.Panic(err)
Expand All @@ -151,6 +155,7 @@ func NewOfflineDatabase(dbFile string, updatedDbFile string) (*OfflineDatabase,
log.Panic(err)
}
odb.database = db
logger.Info("Database updated")
}
}
})
Expand Down

0 comments on commit 4d86334

Please sign in to comment.