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() 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.mu.Lock()
s.Progress.Clear() s.Progress.Clear()
fmt.Println("%s: %s", origin, err) fmt.Printf("[%s] %s: %s\n", origin, filename, err)
s.Progress.RenderBlank() s.Progress.RenderBlank()
s.mu.Unlock() s.mu.Unlock()
return err return err

View File

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