mirror of
https://codeberg.org/scip/kleingebaeck.git
synced 2025-12-16 20:11:01 +01:00
fix #74: warn if about to write to already visited ad, overwrite if -f
This commit is contained in:
21
store.go
21
store.go
@@ -133,3 +133,24 @@ func fileExists(filename string) bool {
|
||||
|
||||
return !info.IsDir()
|
||||
}
|
||||
|
||||
// check if an addir has already been processed by current run and
|
||||
// decide what to do
|
||||
func CheckAdVisited(conf *Config, adname string) bool {
|
||||
if Exists(DirsVisited, adname) {
|
||||
if conf.ForceDownload {
|
||||
slog.Warn("an ad with the same name has already been downloaded, overwriting", "addir", adname)
|
||||
return true
|
||||
}
|
||||
|
||||
// don't overwrite
|
||||
slog.Warn("an ad with the same name has already been downloaded, skipping (use -f to overwrite)", "addir", adname)
|
||||
return false
|
||||
}
|
||||
|
||||
// register
|
||||
DirsVisited[adname] = 1
|
||||
|
||||
// overwrite
|
||||
return true
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user