fixed variable shadowing warnings

This commit is contained in:
Philipp Häfelfinger 2019-04-09 00:16:31 +02:00
parent 4debc22f5c
commit acea32d0b1
5 changed files with 14 additions and 9 deletions

View File

@ -78,7 +78,8 @@ func updatePiwigoCategoriesFromServer(piwigoApi piwigo.CategoryApi, db datastore
}
for _, pwgCat := range categories {
dbCat, err := db.GetCategoryByPiwigoId(pwgCat.Id)
var dbCat datastore.CategoryData
dbCat, err = db.GetCategoryByPiwigoId(pwgCat.Id)
if err == datastore.ErrorRecordNotFound {
logrus.Debugf("Adding category %s", pwgCat.Key)
dbCat = datastore.CategoryData{
@ -125,7 +126,8 @@ func createMissingCategories(piwigoApi piwigo.CategoryApi, db datastore.Category
for _, category := range missingCategories {
logrus.Infof("Creating category %s", category.Key)
parentId, err := getParentId(category, db)
var parentId int
parentId, err = getParentId(category, db)
if err != nil {
return err
}

View File

@ -83,7 +83,8 @@ func checkFileForChangesWorker(workQueue <-chan localFileStructure.FilesystemNod
metadata.FullImagePath = file.Path
metadata.CategoryPath = filepath.Dir(file.Key)
category, err := categoryDb.GetCategoryByKey(metadata.CategoryPath)
var category datastore.CategoryData
category, err = categoryDb.GetCategoryByKey(metadata.CategoryPath)
if err == nil {
metadata.CategoryPiwigoId = category.PiwigoId
} else {
@ -127,10 +128,10 @@ func synchronizeLocalImageMetadataFindFilesToDelete(imageDb datastore.ImageMetad
}
for _, img := range images {
if _, err := os.Stat(img.FullImagePath); os.IsNotExist(err) {
if _, err = os.Stat(img.FullImagePath); os.IsNotExist(err) {
img.UploadRequired = false
img.DeleteRequired = true
err := imageDb.SaveImageMetadata(img)
err = imageDb.SaveImageMetadata(img)
if err != nil {
return err
}

View File

@ -98,7 +98,8 @@ func checkPiwigoForChangedImages(provider datastore.ImageMetadataProvider, piwig
if img.PiwigoId == 0 {
continue
}
state, err := piwigoCtx.ImageCheckFile(img.PiwigoId, img.Md5Sum)
var state int
state, err = piwigoCtx.ImageCheckFile(img.PiwigoId, img.Md5Sum)
if err != nil {
logrus.Warnf("Error during file change check of file %s", img.FullImagePath)
continue

View File

@ -22,7 +22,7 @@ func CalculateFileCheckSums(filePath string) (string, error) {
defer file.Close()
hash := md5.New()
if _, err := io.Copy(hash, file); err != nil {
if _, err = io.Copy(hash, file); err != nil {
logrus.Errorf("Could calculate md5 sum of file %s", filePath)
return "", err
}

View File

@ -217,7 +217,8 @@ func (context *ServerContext) imagesExistOnPiwigoBatch(md5sums []string, existRe
logrus.Tracef("Missing file with md5sum: %s", key)
existResults[key] = 0
} else {
piwigoId, err := strconv.Atoi(value)
var piwigoId int
piwigoId, err = strconv.Atoi(value)
if err != nil {
logrus.Warnf("could not parse piwigoid of file %s", key)
continue
@ -328,7 +329,7 @@ func (context *ServerContext) executePiwigoRequest(formData url.Values, decodedR
}
defer response.Body.Close()
if err := json.NewDecoder(response.Body).Decode(decodedResponse); err != nil {
if err = json.NewDecoder(response.Body).Decode(decodedResponse); err != nil {
logrus.Errorln(err)
return err
}