add debug

This commit is contained in:
Celogeek 2021-12-28 11:03:36 +01:00
parent b6917ae0e1
commit 9beadc7890
Signed by: celogeek
GPG Key ID: E6B7BDCFC446233A
2 changed files with 10 additions and 10 deletions

View File

@ -77,10 +77,10 @@ func (s *FileToUploadStat) Skip() {
s.mu.Unlock()
}
func (s *FileToUploadStat) Error(origin string, err error) error {
func (s *FileToUploadStat) Error(origin string, filename string, err error) error {
s.mu.Lock()
s.Progress.Clear()
fmt.Println("%s: %s", origin, err)
fmt.Printf("[%s] %s: %s\n", origin, filename, err)
s.Progress.RenderBlank()
s.mu.Unlock()
return err

View File

@ -29,7 +29,7 @@ func (p *Piwigo) CheckUploadFile(file *FileToUpload, stat *FileToUploadStat) (er
stat.Fail()
stat.Check()
err = fmt.Errorf("%s: checksum error", file.FullPath())
stat.Error(file.FullPath(), err)
stat.Error("CheckUploadFile", file.FullPath(), err)
return
}
@ -54,7 +54,7 @@ func (p *Piwigo) Upload(file *FileToUpload, stat *FileToUploadStat, nbJobs int,
wg := &sync.WaitGroup{}
chunks, err := Base64Chunker(file.FullPath())
if err != nil {
stat.Error(file.FullPath(), err)
stat.Error("Base64Chunker", file.FullPath(), err)
return
}
@ -83,7 +83,7 @@ func (p *Piwigo) Upload(file *FileToUpload, stat *FileToUploadStat, nbJobs int,
err = p.Post("pwg.images.add", data, &resp)
if err != nil {
stat.Fail()
stat.Error(file.FullPath(), err)
stat.Error("Upload", file.FullPath(), err)
return
}
@ -112,11 +112,11 @@ func (p *Piwigo) UploadChunk(file *FileToUpload, chunks chan *Base64ChunkResult,
if err == nil {
break
}
stat.Error(fmt.Sprintf("UploadChunk %d", i), file.FullPath(), err)
}
stat.Commit(chunk.Size)
if err != nil {
stat.Fail()
stat.Error(file.FullPath(), err)
*ok = false
return
}
@ -136,19 +136,19 @@ func (p *Piwigo) ScanTree(
}
rootPath, err := filepath.Abs(rootPath)
if err != nil {
stat.Error(rootPath, err)
stat.Error("ScanTree Abs", rootPath, err)
return
}
categoriesId, err := p.CategoriesId(parentCategoryId)
if err != nil {
stat.Error(rootPath, err)
stat.Error("ScanTree CategoriesId", rootPath, err)
return
}
dirs, err := ioutil.ReadDir(rootPath)
if err != nil {
stat.Error(rootPath, err)
stat.Error("ScanTree Dir", rootPath, err)
return
}
@ -166,7 +166,7 @@ func (p *Piwigo) ScanTree(
"parent": []string{fmt.Sprint(parentCategoryId)},
}, &resp)
if err != nil {
stat.Error(rootPath, err)
stat.Error("ScanTree Categories Add", rootPath, err)
return
}
categoryId = resp.Id