Handle file import digest

This commit is contained in:
nemunaire 2017-01-04 01:30:24 +01:00
parent 0b4e8a233c
commit 1bd403cd8c
4 changed files with 43 additions and 10 deletions

View file

@ -4,6 +4,7 @@ import (
"bufio"
"crypto/sha512"
"encoding/base32"
"encoding/hex"
"encoding/json"
"errors"
"fmt"
@ -23,7 +24,7 @@ var RapidImport bool
type uploadedFile struct {
URI string
Digest []byte
Digest string
Path string
Parts []string
}
@ -94,7 +95,11 @@ func createExerciceFile(exercice fic.Exercice, body []byte) (interface{}, error)
}
}
return exercice.ImportFile(pathname, fromURI)
if digest, err := hex.DecodeString(uf.Digest); err != nil {
return nil, err
} else {
return exercice.ImportFile(pathname, fromURI, digest)
}
}
func getCloudFile(pathname string, dest string) error {