From 3c27031eaea4172352e9a72b140df6f0b05fe56b Mon Sep 17 00:00:00 2001 From: minie4 Date: Mon, 8 Jan 2024 18:01:47 +0100 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Skip=20downloading=20files=20that?= =?UTF-8?q?=20already=20exist=20locally?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/main.go b/main.go index e436b67..cb8b5dd 100644 --- a/main.go +++ b/main.go @@ -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)