Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Additional fixes #4

Merged
merged 2 commits into from
Oct 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ module changeme
go 1.18

require (
github.com/fatih/color v1.15.0
github.com/mmcloughlin/geohash v0.10.0
github.com/rwcarlsen/goexif v0.0.0-20190401172101-9e8deecbddbd
github.com/wailsapp/wails/v2 v2.6.0
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY=
github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto=
github.com/fatih/color v1.15.0 h1:kOqh6YHBtK8aywxGerMG2Eq3H6Qgoqeo13Bk2Mv/nBs=
github.com/fatih/color v1.15.0/go.mod h1:0h5ZqXfHYED7Bhv2ZJamyIOUej9KtShiJESRwBDUSsw=
github.com/go-ole/go-ole v1.2.6 h1:/Fpf6oFPoeFik9ty7siob0G6Ke8QvQEuVcuChpwXzpY=
github.com/go-ole/go-ole v1.2.6/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0=
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
Expand Down
15 changes: 9 additions & 6 deletions path_parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package main
import (
"encoding/json"
"fmt"
"github.com/fatih/color"
"github.com/mmcloughlin/geohash"
"github.com/rwcarlsen/goexif/exif"
"github.com/wailsapp/wails/v2/pkg/runtime"
Expand All @@ -14,6 +15,7 @@ import (
"os"
"path/filepath"
"regexp"
"strings"
"time"
)

Expand Down Expand Up @@ -204,7 +206,8 @@ func ProcessPathSubstitution(placeholderText string, metadata *ImageMetadata) st
}

placeholderText += "/" + filepath.Base(metadata.FilePath)
placeholderText = NormalizePath(placeholderText)
placeholderText = strings.Replace(NormalizePath(placeholderText), "/, /", "/", -1)
placeholderText = strings.Replace(placeholderText, ", /", "/", -1)

return placeholderText
}
Expand Down Expand Up @@ -237,31 +240,31 @@ func RelocateFiles(a *App) {

sourceFile, err := os.Open(a.substitutions[i].From)
if err != nil {
fmt.Println("Source file error", err)
color.Red("Source file error: %s", err)
continue
}

destinationFile, err := os.Create(destinationPath)
if err != nil {
fmt.Println("Destination file error", err)
color.Red("Destination file error: %s", err)
sourceFile.Close()
continue
}
defer destinationFile.Close()

if _, err := io.Copy(destinationFile, sourceFile); err != nil {
fmt.Println("Failed to copy", err)
color.Red("Failed to copy: %s", err)
sourceFile.Close()
continue
}

sourceFile.Close()

if a.moveOrCopy == "move" {
fmt.Println("Removing", a.substitutions[i].From)
color.Yellow("Removing %s", a.substitutions[i].From)
err := os.Remove(a.substitutions[i].From)
if err != nil {
fmt.Println("Remove error", err)
color.Red("Remove error: %s", err)
continue
}
}
Expand Down