package main import ( "log" "os" ) func release_branch(branch string, source_dir string, target_dir string, dryrun bool) { checkOldFolder, _ := os.ReadDir(source_dir) checkNewFolder, _ := os.ReadDir(target_dir) var newImages bool = false if len(checkOldFolder) > 0 { newImages = true } if newImages { // delete old firmware files in public folder for _, file := range checkNewFolder { if !(dryrun) { err := os.RemoveAll(target_dir + file.Name()) if err != nil { log.Println("error deleting file: ", err) } else { log.Println("removed file: ", file.Name()) } } else { log.Println("DRYRUN: delete folder :", file.Name()) } } //move new files to folder for _, file := range checkOldFolder { if !(dryrun) { os.Rename(source_dir+file.Name(), target_dir+file.Name()) log.Println("moved file: ", file.Name()) } else { log.Println("DRYRUN: move folder: ", file.Name()) } } } }