admin: new route to check file on disk

This commit is contained in:
nemunaire 2018-08-19 22:19:49 +02:00 committed by Pierre-Olivier Mercier
commit 20dfd99ec0
4 changed files with 27 additions and 6 deletions

View file

@ -261,3 +261,14 @@ func ClearFiles() (int64, error) {
func (f EFile) GetOrigin() string {
return f.origin
}
// CheckFileOnDisk recalculates the hash of the file on disk.
func (f EFile) CheckFileOnDisk() error {
if _, size, err := checkFileHash(path.Join(FilesDir, f.Path), f.Checksum); err != nil {
return err
} else if size == 0 {
return errors.New("Empty file!")
} else {
return nil
}
}