mirror of
https://github.com/celogeek/piwigo-cli.git
synced 2025-05-25 10:12:37 +02:00
add checked
This commit is contained in:
parent
423d99aaf6
commit
0981f35615
@ -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())
|
||||||
|
@ -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")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user