diff --git a/internal/piwigo/file_to_upload.go b/internal/piwigo/file_to_upload.go index 323137c..baebc4c 100644 --- a/internal/piwigo/file_to_upload.go +++ b/internal/piwigo/file_to_upload.go @@ -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()) diff --git a/internal/piwigo/files.go b/internal/piwigo/files.go index b1a3515..9a8fae8 100644 --- a/internal/piwigo/files.go +++ b/internal/piwigo/files.go @@ -25,13 +25,14 @@ func (p *Piwigo) FileExists(md5 string) bool { } func (p *Piwigo) Upload(file *FileToUpload, stat *FileToUploadStat, nbJobs int, hasVideoJS bool) error { - if file.MD5() == "" { - stat.Fail() - return errors.New("checksum error") + if !file.Checked() { + if file.MD5() == "" { + stat.Fail() + return errors.New("checksum error") + } + stat.Check() } - stat.Check() - if p.FileExists(file.MD5()) { stat.Skip() return errors.New("file already exists")