Ajout récupération de fichier (fingerprint à check)
This commit is contained in:
@@ -8,9 +8,9 @@ import (
|
||||
)
|
||||
|
||||
// SendFile Envoie d'un fichier local sur le réseau
|
||||
func SendFile(fileName string, fileSize int, writer *bufio.Writer) bool {
|
||||
func SendFile(filePath string, fileSize int, writer *bufio.Writer) bool {
|
||||
// Ouverture du fichier
|
||||
file, fileErr := os.Open(fmt.Sprintf("/home/benjamin/sbe/%s", fileName))
|
||||
file, fileErr := os.Open(fmt.Sprintf("%s", filePath))
|
||||
if fileErr != nil {
|
||||
return false
|
||||
}
|
||||
@@ -25,5 +25,5 @@ func SendFile(fileName string, fileSize int, writer *bufio.Writer) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
return false
|
||||
return true
|
||||
}
|
||||
|
||||
@@ -10,6 +10,12 @@ import (
|
||||
)
|
||||
|
||||
func HashFileCompare(path string, fingerPrint string) bool {
|
||||
sum := GenFingerPrint(path)
|
||||
|
||||
return fingerPrint == fmt.Sprintf("%x", sum)
|
||||
}
|
||||
|
||||
func GenFingerPrint(path string) []byte {
|
||||
f, err := os.Open(path)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
@@ -24,8 +30,5 @@ func HashFileCompare(path string, fingerPrint string) bool {
|
||||
}
|
||||
sum := hash.Sum(nil)
|
||||
|
||||
fmt.Printf("%x\n", sum)
|
||||
|
||||
println(fingerPrint, fmt.Sprintf("%x", sum))
|
||||
return fingerPrint == fmt.Sprintf("%x", sum)
|
||||
return sum
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user