fix #74: warn if about to write to already visited ad, overwrite if -f

This commit is contained in:
2024-02-10 14:06:06 +01:00
committed by T.v.Dein
parent ed78731b3c
commit 612ed2aa79
11 changed files with 54 additions and 8 deletions

View File

@@ -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
}