Skip downloading files that already exist locally

This commit is contained in:
2024-01-08 18:01:47 +01:00
parent 18c7ca0456
commit 3c27031eae

View File

@ -79,12 +79,17 @@ func main() {
return "Downloading files"
})
for _, resource := range resouceList {
var out_path = "./out/" + course.Title + "/" + resource.Title
if _, err := os.Stat(out_path); err == nil {
logger.Info("Skipping element", "course", course.Title, "element", resource.Title, "id", resource.ElementID)
continue
}
logger.Info("Downloading element", "course", course.Title, "element", resource.Title, "id", resource.ElementID)
wg.Add(1)
current_tasks++
go func(resource itslearning.Resource) {
defer wg.Done()
itslearning.DownloadElement(itsl, resource.ElementID, "./out/"+course.Title+"/"+resource.Title)
itslearning.DownloadElement(itsl, resource.ElementID, out_path)
bar.Incr()
current_tasks--
}(resource)