Backend: Improve log messages

Signed-off-by: Michael Mayer <michael@liquidbytes.net>
This commit is contained in:
Michael Mayer 2020-07-15 11:28:54 +02:00
parent 36919b69a0
commit b1b6e438f7
9 changed files with 22 additions and 21 deletions

View file

@ -78,7 +78,7 @@ func StartImport(router *gin.RouterGroup) {
if subPath != "" && path != conf.ImportPath() && fs.IsEmpty(path) {
if err := os.Remove(path); err != nil {
log.Errorf("import: could not delete empty folder %s: %s", txt.Quote(path), err)
log.Errorf("import: failed deleting empty folder %s: %s", txt.Quote(path), err)
} else {
log.Infof("import: deleted empty folder %s", txt.Quote(path))
}

View file

@ -134,7 +134,7 @@ func DownloadZip(router *gin.RouterGroup) {
c.File(zipFileName)
if err := os.Remove(zipFileName); err != nil {
log.Errorf("zip: could not remove %s (%s)", txt.Quote(zipFileName), err.Error())
log.Errorf("zip: failed removing %s (%s)", txt.Quote(zipFileName), err.Error())
}
})
}

View file

@ -183,7 +183,7 @@ func (imp *Import) Start(opt ImportOptions) map[string]bool {
for _, directory := range directories {
if fs.IsEmpty(directory) {
if err := os.Remove(directory); err != nil {
log.Errorf("import: could not delete empty folder %s (%s)", txt.Quote(fs.RelName(directory, importPath)), err)
log.Errorf("import: failed deleting empty folder %s (%s)", txt.Quote(fs.RelName(directory, importPath)), err)
} else {
log.Infof("import: deleted empty folder %s", txt.Quote(fs.RelName(directory, importPath)))
}
@ -199,7 +199,7 @@ func (imp *Import) Start(opt ImportOptions) map[string]bool {
}
if err := os.Remove(file); err != nil {
log.Errorf("import: could not remove %s (%s)", txt.Quote(fs.RelName(file, importPath)), err.Error())
log.Errorf("import: failed removing %s (%s)", txt.Quote(fs.RelName(file, importPath)), err.Error())
}
}
}

View file

@ -45,7 +45,7 @@ func ImportWorker(jobs <-chan ImportJob) {
if destinationFilename, err := imp.DestinationFilename(related.Main, f); err == nil {
if err := os.MkdirAll(path.Dir(destinationFilename), os.ModePerm); err != nil {
log.Errorf("import: could not create folders (%s)", err.Error())
log.Errorf("import: failed creating folders for %s (%s)", txt.Quote(f.BaseName()), err.Error())
}
if related.Main.HasSameName(f) {
@ -57,11 +57,11 @@ func ImportWorker(jobs <-chan ImportJob) {
if opt.Move {
if err := f.Move(destinationFilename); err != nil {
log.Errorf("import: could not move file to %s (%s)", txt.Quote(fs.RelName(destinationMainFilename, imp.originalsPath())), err.Error())
log.Errorf("import: failed moving file to %s (%s)", txt.Quote(fs.RelName(destinationMainFilename, imp.originalsPath())), err.Error())
}
} else {
if err := f.Copy(destinationFilename); err != nil {
log.Errorf("import: could not copy file to %s (%s)", txt.Quote(fs.RelName(destinationMainFilename, imp.originalsPath())), err.Error())
log.Errorf("import: failed copying file to %s (%s)", txt.Quote(fs.RelName(destinationMainFilename, imp.originalsPath())), err.Error())
}
}
} else {
@ -69,7 +69,7 @@ func ImportWorker(jobs <-chan ImportJob) {
if opt.RemoveExistingFiles {
if err := f.Remove(); err != nil {
log.Errorf("import: could not delete %s (%s)", txt.Quote(fs.RelName(f.FileName(), importPath)), err.Error())
log.Errorf("import: failed deleting %s (%s)", txt.Quote(f.BaseName()), err.Error())
} else {
log.Infof("import: deleted %s (already exists)", txt.Quote(relativeFilename))
}

View file

@ -29,7 +29,7 @@ func IndexMain(related *RelatedFiles, ind *Index, opt IndexOptions) (result Inde
if opt.Convert && !f.HasJpeg() {
if jpegFile, err := ind.convert.ToJpeg(f); err != nil {
result.Err = fmt.Errorf("index: creating jpeg failed (%s)", err.Error())
result.Err = fmt.Errorf("index: failed converting %s to jpeg (%s)", txt.Quote(f.BaseName()), err.Error())
result.Status = IndexFailed
return result
@ -37,7 +37,7 @@ func IndexMain(related *RelatedFiles, ind *Index, opt IndexOptions) (result Inde
log.Infof("index: %s created", fs.RelName(jpegFile.FileName(), ind.originalsPath()))
if err := jpegFile.ResampleDefault(ind.thumbPath(), false); err != nil {
result.Err = fmt.Errorf("index: could not create default thumbnails (%s)", err.Error())
result.Err = fmt.Errorf("index: failed creating thumbnails for %s (%s)", txt.Quote(f.BaseName()), err.Error())
result.Status = IndexFailed
return result
@ -49,7 +49,7 @@ func IndexMain(related *RelatedFiles, ind *Index, opt IndexOptions) (result Inde
if ind.conf.SidecarJson() && !f.HasJson() {
if jsonFile, err := ind.convert.ToJson(f); err != nil {
log.Errorf("index: creating json sidecar file failed (%s)", err.Error())
log.Errorf("index: failed creating json sidecar for %s (%s)", txt.Quote(f.BaseName()), err.Error())
} else {
log.Infof("index: %s created", fs.RelName(jsonFile.FileName(), ind.originalsPath()))
}
@ -59,7 +59,7 @@ func IndexMain(related *RelatedFiles, ind *Index, opt IndexOptions) (result Inde
if result.Indexed() && f.IsJpeg() {
if err := f.ResampleDefault(ind.thumbPath(), false); err != nil {
log.Errorf("index: could not create default thumbnails (%s)", err.Error())
log.Errorf("index: failed creating thumbnails for %s (%s)", txt.Quote(f.BaseName()), err.Error())
query.SetFileError(result.FileUID, err.Error())
}
}
@ -107,7 +107,7 @@ func IndexRelated(related RelatedFiles, ind *Index, opt IndexOptions) (result In
if res.Indexed() && f.IsJpeg() {
if err := f.ResampleDefault(ind.thumbPath(), false); err != nil {
log.Errorf("index: could not create default thumbnails (%s)", err.Error())
log.Errorf("index: failed creating thumbnails for %s (%s)", txt.Quote(f.BaseName()), err.Error())
query.SetFileError(res.FileUID, err.Error())
}
}

View file

@ -493,7 +493,7 @@ func (m *MediaFile) Move(dest string) error {
}
if err := os.Rename(m.fileName, dest); err != nil {
log.Debugf("could not rename file, falling back to copy and delete: %s", err.Error())
log.Debugf("failed renaming file, fallback to copy and delete: %s", err.Error())
} else {
m.fileName = dest
@ -802,8 +802,9 @@ func (m *MediaFile) Thumbnail(path string, typeName string) (filename string, er
thumbnail, err := thumb.FromFile(m.FileName(), m.Hash(), path, thumbType.Width, thumbType.Height, thumbType.Options...)
if err != nil {
log.Errorf("mediafile: could not create thumbnail (%s)", err)
return "", fmt.Errorf("mediafile: could not create thumbnail (%s)", err)
err = fmt.Errorf("mediafile: failed creating thumbnail for %s (%s)", txt.Quote(m.BaseName()), err)
log.Error(err)
return "", err
}
return thumbnail, nil
@ -850,7 +851,7 @@ func (m *MediaFile) ResampleDefault(thumbPath string, force bool) (err error) {
}
if fileName, err := thumb.Filename(hash, thumbPath, thumbType.Width, thumbType.Height, thumbType.Options...); err != nil {
log.Errorf("mediafile: could not create %s (%s)", txt.Quote(name), err)
log.Errorf("mediafile: failed creating %s (%s)", txt.Quote(name), err)
return err
} else {
@ -881,7 +882,7 @@ func (m *MediaFile) ResampleDefault(thumbPath string, force bool) (err error) {
}
if err != nil {
log.Errorf("mediafile: could not create %s (%s)", txt.Quote(name), err)
log.Errorf("mediafile: failed creating %s (%s)", txt.Quote(name), err)
return err
}

View file

@ -1586,7 +1586,7 @@ func TestMediaFile_Thumbnail(t *testing.T) {
thumbnail, err := image.Thumbnail(thumbsPath, "tile_500")
assert.EqualError(t, err, "mediafile: could not create thumbnail (image: unknown format)")
assert.EqualError(t, err, "mediafile: failed creating thumbnail for canon_eos_6d.xmp (image: unknown format)")
t.Log(thumbnail)
})

View file

@ -90,7 +90,7 @@ func (worker *Share) Start() (err error) {
if _, ok := existingDirs[dir]; !ok {
if err := client.CreateDir(dir); err != nil {
log.Errorf("share-worker: could not create folder %s", dir)
log.Errorf("share-worker: failed creating folder %s", dir)
continue
}
}

View file

@ -44,7 +44,7 @@ func (worker *Sync) upload(a entity.Account) (complete bool, err error) {
if _, ok := existingDirs[remoteDir]; !ok {
if err := client.CreateDir(remoteDir); err != nil {
log.Errorf("sync-worker: could not create remote folder %s", remoteDir)
log.Errorf("sync-worker: failed creating remote folder %s", remoteDir)
continue // try again next time
}
}