diff --git a/go.mod b/go.mod index 82b37ed..cb99491 100644 --- a/go.mod +++ b/go.mod @@ -3,6 +3,8 @@ module git.haefelfinger.net/philipp.haefelfinger/SideCarJpegCleaner go 1.12 require ( - github.com/sirupsen/logrus v1.4.2 + github.com/konsorten/go-windows-terminal-sequences v1.0.1 // indirect + github.com/sirupsen/logrus v1.9.0 + github.com/stretchr/objx v0.1.1 // indirect github.com/vharitonsky/iniflags v0.0.0-20180513140207-a33cd0b5f3de ) diff --git a/go.sum b/go.sum index 5e679a1..3c57c21 100644 --- a/go.sum +++ b/go.sum @@ -1,12 +1,21 @@ +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/konsorten/go-windows-terminal-sequences v1.0.1 h1:mweAR1A6xJ3oS2pRaGiHgQ4OO8tzTaLawm8vnODuwDk= github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/sirupsen/logrus v1.4.2 h1:SPIRibHv4MatM3XXNO2BJeFLZwZ2LvZgfQ5+UNI2im4= github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= +github.com/sirupsen/logrus v1.9.0 h1:trlNQbNUG3OdDrDil03MCb1H2o9nJ1x4/5LYw7byDE0= +github.com/sirupsen/logrus v1.9.0/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= +github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/vharitonsky/iniflags v0.0.0-20180513140207-a33cd0b5f3de h1:fkw+7JkxF3U1GzQoX9h69Wvtvxajo5Rbzy6+YMMzPIg= github.com/vharitonsky/iniflags v0.0.0-20180513140207-a33cd0b5f3de/go.mod h1:irMhzlTz8+fVFj6CH2AN2i+WI5S6wWFtK3MBCIxIpyI= golang.org/x/sys v0.0.0-20190422165155-953cdadca894 h1:Cz4ceDQGXuKRnVBDTS23GTn/pU5OE2C0WrNTOYK1Uuc= golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8 h1:0A+M6Uqn+Eje4kHMK80dtF3JCXC4ykBgQG4Fe06QRhQ= +golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/internal/app/app.go b/internal/app/app.go index 0b722b4..7b2e11d 100644 --- a/internal/app/app.go +++ b/internal/app/app.go @@ -76,12 +76,15 @@ func getJpegsWithoutRawSideCar(jpgFiles []string) []string { for _, jpgFile := range jpgFiles { dir, fileName := filepath.Split(jpgFile) - newFileName := filenameWithoutExtension(fileName) + ".cr2" - newFilePath := filepath.Join(dir, newFileName) - - if exists, err := fileExists(newFilePath); exists { - logrus.Debugf("Found existing sidecar, keeping jpeg %s", jpgFile) + cr2FileName := filenameWithoutExtension(fileName) + ".cr2" + cr2FilePath := filepath.Join(dir, cr2FileName) + cr3FileName := filenameWithoutExtension(fileName) + ".cr3" + cr3FilePath := filepath.Join(dir, cr3FileName) + if exists, err := fileExists(cr2FilePath); exists { + logrus.Debugf("Found existing cr2 sidecar, keeping jpeg %s", jpgFile) + } else if exists, err = fileExists(cr3FilePath); exists { + logrus.Debugf("Found existing cr3 sidecar, keeping jpeg %s", jpgFile) } else if err == nil && !exists { logrus.Infof("Found jpeg with missing raw file, schedule for delete %s", jpgFile) filesWithMissingSidecar = append(filesWithMissingSidecar, jpgFile)