sync: Export DownloadExerciceFile function
This commit is contained in:
parent
f3cdf1afca
commit
c3353572e6
3 changed files with 11 additions and 11 deletions
|
@ -194,9 +194,9 @@ func CheckExerciceFiles(i Importer, exercice *fic.Exercice, exceptions *CheckExc
|
|||
|
||||
if pf, exists := paramsFiles[fname]; exists && pf.URL != "" {
|
||||
if li, ok := i.(LocalImporter); ok {
|
||||
errs = multierr.Append(errs, downloadExerciceFile(paramsFiles[fname], li.GetLocalPath(dest), exercice, false))
|
||||
errs = multierr.Append(errs, DownloadExerciceFile(paramsFiles[fname], li.GetLocalPath(dest), exercice, false))
|
||||
} else {
|
||||
errs = multierr.Append(errs, downloadExerciceFile(paramsFiles[fname], dest, exercice, false))
|
||||
errs = multierr.Append(errs, DownloadExerciceFile(paramsFiles[fname], dest, exercice, false))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -253,7 +253,7 @@ func CheckExerciceFiles(i Importer, exercice *fic.Exercice, exceptions *CheckExc
|
|||
}
|
||||
}
|
||||
|
||||
file := exercice.NewDummyFile(path.Join(exercice.Path, "files", fname), getDestinationFilePath(path.Join(exercice.Path, "files", fname), nil), (*hash512).Sum(nil), digest_shown, disclaimer, size)
|
||||
file := exercice.NewDummyFile(path.Join(exercice.Path, "files", fname), GetDestinationFilePath(path.Join(exercice.Path, "files", fname), nil), (*hash512).Sum(nil), digest_shown, disclaimer, size)
|
||||
|
||||
// Call checks hooks
|
||||
for _, h := range hooks.fileHooks {
|
||||
|
@ -269,8 +269,8 @@ func CheckExerciceFiles(i Importer, exercice *fic.Exercice, exceptions *CheckExc
|
|||
return
|
||||
}
|
||||
|
||||
// downloadExerciceFile is responsible to fetch remote files.
|
||||
func downloadExerciceFile(pf ExerciceFile, dest string, exercice *fic.Exercice, force bool) (errs error) {
|
||||
// DownloadExerciceFile is responsible to fetch remote files.
|
||||
func DownloadExerciceFile(pf ExerciceFile, dest string, exercice *fic.Exercice, force bool) (errs error) {
|
||||
if st, err := os.Stat(dest); !force && !os.IsNotExist(err) {
|
||||
resp, err := http.Head(pf.URL)
|
||||
if err == nil && resp.ContentLength == st.Size() {
|
||||
|
@ -364,7 +364,7 @@ func SyncExerciceFiles(i Importer, exercice *fic.Exercice, exceptions *CheckExce
|
|||
var f interface{}
|
||||
|
||||
if pf, exists := paramsFiles[fname]; exists && pf.URL != "" {
|
||||
dest := getDestinationFilePath(pf.URL, &pf.Filename)
|
||||
dest := GetDestinationFilePath(pf.URL, &pf.Filename)
|
||||
|
||||
if _, err := os.Stat(dest); !os.IsNotExist(err) {
|
||||
if d, err := actionAfterImport(dest, pf.URL); err == nil {
|
||||
|
@ -373,7 +373,7 @@ func SyncExerciceFiles(i Importer, exercice *fic.Exercice, exceptions *CheckExce
|
|||
}
|
||||
|
||||
if f == nil {
|
||||
errs = multierr.Append(errs, downloadExerciceFile(paramsFiles[fname], dest, exercice, false))
|
||||
errs = multierr.Append(errs, DownloadExerciceFile(paramsFiles[fname], dest, exercice, false))
|
||||
|
||||
f, err = actionAfterImport(dest, pf.URL)
|
||||
}
|
||||
|
|
Reference in a new issue