add checked

This commit is contained in:
Celogeek 2021-12-27 11:50:25 +01:00
parent 423d99aaf6
commit 0981f35615
Signed by: celogeek
GPG Key ID: E6B7BDCFC446233A
2 changed files with 10 additions and 5 deletions

View File

@ -25,6 +25,10 @@ func (f *FileToUpload) FullPath() string {
return filepath.Join(f.Dir, f.Name)
}
func (f *FileToUpload) Checked() bool {
return f.md5 != nil
}
func (f *FileToUpload) MD5() string {
if f.md5 == nil {
md5, err := Md5File(f.FullPath())

View File

@ -25,12 +25,13 @@ func (p *Piwigo) FileExists(md5 string) bool {
}
func (p *Piwigo) Upload(file *FileToUpload, stat *FileToUploadStat, nbJobs int, hasVideoJS bool) error {
if !file.Checked() {
if file.MD5() == "" {
stat.Fail()
return errors.New("checksum error")
}
stat.Check()
}
if p.FileExists(file.MD5()) {
stat.Skip()