Skip to content

Commit

Permalink
Fixed create/remove file logs
Browse files Browse the repository at this point in the history
  • Loading branch information
HardDie committed Jul 29, 2021
1 parent 045514c commit 13c5558
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,20 @@ func putCache(cfg *Config, bw *BoltWrapper, name string, data []byte) (err error
}

func updateCache(cfg *Config) (err error) {
// Check if cache folder exists
if !isFileExists(*cfg.DBSource) {
if err = os.MkdirAll(*cfg.DBSource, os.ModePerm); err != nil {
return
}
fmt.Printf("Cache folder %s were created!\n", *cfg.DBSource)
}

// Delete DB if exists
if isFileExists(*cfg.DBSource + "/" + DBDefaultName) {
if err = os.Remove(*cfg.DBSource + "/" + DBDefaultName); err != nil {
return
}
fmt.Printf("Cache file %s were removed!\n", *cfg.DBSource+"/"+DBDefaultName)
}

// Download archive with all pages
Expand All @@ -104,6 +113,7 @@ func updateCache(cfg *Config) (err error) {
return
}
defer func() { _ = bw.Close() }()
fmt.Printf("Cache file %s were created!\n", *cfg.DBSource+"/"+DBDefaultName)

fmt.Println("Start caching...")

Expand Down

0 comments on commit 13c5558

Please sign in to comment.