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) return filepath.Join(f.Dir, f.Name)
} }
func (f *FileToUpload) Checked() bool {
return f.md5 != nil
}
func (f *FileToUpload) MD5() string { func (f *FileToUpload) MD5() string {
if f.md5 == nil { if f.md5 == nil {
md5, err := Md5File(f.FullPath()) md5, err := Md5File(f.FullPath())

View File

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