Skip to content

Commit 0780ffa

Browse files
committed
replaced package gitlab.cim/mipimipi/go-utils by packages gitlab.com/go-utilities/*
Signed-off-by: Michael Picht <[email protected]>
1 parent 992ef50 commit 0780ffa

18 files changed

+69
-111
lines changed

cmd/smsync/cli.go

+1-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
// SPDX-FileCopyrightText: 2018-2020 Michael Picht <[email protected]>
2-
//
3-
// SPDX-License-Identifier: GPL-3.0-or-later
4-
51
package main
62

73
// cli.go implements the command line interface for smsync.
@@ -15,7 +11,7 @@ import (
1511
)
1612

1713
var preamble = `smsync (Smart Music Sync) ` + Version + `
18-
Copyright (C) 2018-2020 Michael Picht <https://github.com/mipimipi/smsync>`
14+
Copyright (C) 2018-2022 Michael Picht <https://github.com/mipimipi/smsync>`
1915

2016
var helpTemplate = preamble + `
2117
{{with (or .Long .Short)}}{{. | trimTrailingWhitespaces}}

cmd/smsync/main.go

-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
// SPDX-FileCopyrightText: 2018-2020 Michael Picht <[email protected]>
2-
//
3-
// SPDX-License-Identifier: GPL-3.0-or-later
4-
51
package main
62

73
import (

cmd/smsync/print.go

+3-7
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
// SPDX-FileCopyrightText: 2018-2020 Michael Picht <[email protected]>
2-
//
3-
// SPDX-License-Identifier: GPL-3.0-or-later
4-
51
package main
62

73
import (
@@ -11,7 +7,7 @@ import (
117
"time"
128

139
log "github.com/sirupsen/logrus"
14-
"gitlab.com/mipimipi/go-utils"
10+
t "gitlab.com/go-utilities/time"
1511
"gitlab.com/mipimipi/smsync/internal/smsync"
1612
)
1713

@@ -94,7 +90,7 @@ func printFinal(trck *smsync.Tracking, verbose bool) {
9490
} else {
9591
fmt.Printf("\n:: Done :)\n")
9692
}
97-
split := utils.SplitDuration(trck.Elapsed)
93+
split := t.SplitDuration(trck.Elapsed)
9894
fmt.Printf(" Processed %d files and directories in %s\n",
9995
trck.Done,
10096
fmt.Sprintf("%dh %02dmin %02ds",
@@ -140,7 +136,7 @@ func printProgress(trck *smsync.Tracking, first, wantstop bool) {
140136

141137
// local function to print durations as formatted string (HH:MM:SS)
142138
split := func(d time.Duration) string {
143-
sp := utils.SplitDuration(d)
139+
sp := t.SplitDuration(d)
144140
return fmt.Sprintf("%02d:%02d:%02d", sp[time.Hour], sp[time.Minute], sp[time.Second])
145141
}
146142

cmd/smsync/sync.go

+5-9
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
// SPDX-FileCopyrightText: 2018-2020 Michael Picht <[email protected]>
2-
//
3-
// SPDX-License-Identifier: GPL-3.0-or-later
4-
51
package main
62

73
import (
@@ -12,8 +8,8 @@ import (
128

139
"github.com/eiannone/keyboard"
1410
log "github.com/sirupsen/logrus"
15-
"gitlab.com/mipimipi/go-utils"
16-
"gitlab.com/mipimipi/go-utils/file"
11+
"gitlab.com/go-utilities/file"
12+
"gitlab.com/go-utilities/msg"
1713
"gitlab.com/mipimipi/smsync/internal/smsync"
1814
)
1915

@@ -131,7 +127,7 @@ func synchronize(level log.Level, verbose bool) error {
131127
// print summary and ask user for OK
132128
printCfgSummary(cfg)
133129
if !cli.noConfirm {
134-
if !utils.UserOK("\n:: Start synchronization") {
130+
if !msg.UserOK("\n:: Start synchronization") {
135131
log.Infof("Synchronization not started due to user input")
136132
defer smsync.CleanUp(cfg)
137133
return nil
@@ -142,7 +138,7 @@ func synchronize(level log.Level, verbose bool) error {
142138
runtime.GOMAXPROCS(int(cfg.NumCpus))
143139

144140
// start automatic progress string which increments every second
145-
stop, confirm := utils.ProgressStr(":: Find differences (this can take a few minutes)", 1000)
141+
stop, confirm := msg.ProgressStr(":: Find differences (this can take a few minutes)", 1000)
146142

147143
// get files and directories that need to be synched
148144
files := smsync.GetSyncFiles(cfg, cli.init)
@@ -162,7 +158,7 @@ func synchronize(level log.Level, verbose bool) error {
162158

163159
// print summary and ask user for OK to continue
164160
if !cli.noConfirm {
165-
if !utils.UserOK(fmt.Sprintf("\n:: %d files and directories to be synchronized. Continue", len(*files))) {
161+
if !msg.UserOK(fmt.Sprintf("\n:: %d files and directories to be synchronized. Continue", len(*files))) {
166162
log.Infof("Synchronization not started due to user input")
167163
smsync.CleanUp(cfg)
168164
return nil

go.mod

+8-2
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,19 @@ require (
77
github.com/ricochet2200/go-disk-usage/du v0.0.0-20210707232629-ac9918953285
88
github.com/sirupsen/logrus v1.9.0
99
github.com/spf13/cobra v1.5.0
10-
gitlab.com/mipimipi/go-utils v0.1.1
10+
gitlab.com/go-utilities/file v0.2.0
11+
gitlab.com/go-utilities/filepath v0.1.0
12+
gitlab.com/go-utilities/msg v0.1.0
13+
gitlab.com/go-utilities/reflect v0.1.0
14+
gitlab.com/go-utilities/strings v0.1.0
15+
gitlab.com/go-utilities/time v0.1.0
16+
gitlab.com/go-utilities/workerpool v0.1.0
1117
gopkg.in/yaml.v2 v2.4.0
1218
)
1319

1420
require (
1521
github.com/inconshreveable/mousetrap v1.0.1 // indirect
1622
github.com/logrusorgru/aurora v2.0.3+incompatible // indirect
1723
github.com/spf13/pflag v1.0.5 // indirect
18-
golang.org/x/sys v0.0.0-20220818161305-2296e01440c6 // indirect
24+
golang.org/x/sys v0.0.0-20220825204002-c680a09ffe64 // indirect
1925
)

go.sum

+16-4
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,23 @@ github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An
2323
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
2424
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
2525
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
26-
gitlab.com/mipimipi/go-utils v0.1.1 h1:cU2666TMo8pgUI8GuC//WMgw/Yxd2dI9HldNwPR6hyU=
27-
gitlab.com/mipimipi/go-utils v0.1.1/go.mod h1:nDpzqCLSvetvuEEWTtvR9S5R/UuLMUlSgSzHkwVWz7M=
26+
gitlab.com/go-utilities/file v0.2.0 h1:7aGMe9HyHoiaYLLZOllcRUzImQ1T2/07NZtS/OgAtsY=
27+
gitlab.com/go-utilities/file v0.2.0/go.mod h1:nuhefxn/dQ7HXWrio1agnXKfiZtX3oaKwd8MoG+zaZg=
28+
gitlab.com/go-utilities/filepath v0.1.0 h1:V55zyDyxISUs6jgz9XTVdHhybXrxBaplepaRls5KLAQ=
29+
gitlab.com/go-utilities/filepath v0.1.0/go.mod h1:pcdvc5tl6Srh2YN8no+Ohf4Kn6rHvWsEl2QkNLL6we0=
30+
gitlab.com/go-utilities/msg v0.1.0 h1:RGXMubqQZvfooKMklrXRgY6E12ua8ph2lf0VBNHkFJM=
31+
gitlab.com/go-utilities/msg v0.1.0/go.mod h1:xsnANi955os05XQ7lpIRe+kmCH6smn/OqT8UJDaVoJk=
32+
gitlab.com/go-utilities/reflect v0.1.0 h1:j8nyGJy/deaJvwyyMiIMoBzIMIkA7FUVUoud1sGlR4w=
33+
gitlab.com/go-utilities/reflect v0.1.0/go.mod h1:BYNAOKctyRnhC7pW6M0iJnIakRBx+Icyaapim68/pkY=
34+
gitlab.com/go-utilities/strings v0.1.0 h1:ttopj5mmN/UEXM/wDB9VCs1GCWWQX3YkSYy0XpMZM9k=
35+
gitlab.com/go-utilities/strings v0.1.0/go.mod h1:O0jkUMXJpRVZeGQGlCKqBKjCu1Qa8YIq2mnBuLlZSJk=
36+
gitlab.com/go-utilities/time v0.1.0 h1:H0St0R7kKEKVEcUkEQO+dRYtHZ5qDBHoBTj/KY5xtA4=
37+
gitlab.com/go-utilities/time v0.1.0/go.mod h1:CUCynb7yIE/B5OkvyXmcB1NLcrlcp0SULWO34txwubw=
38+
gitlab.com/go-utilities/workerpool v0.1.0 h1:/umfHItxHEWUjBMq1mjllFgiRA9j41t4d/9NIV0+vJQ=
39+
gitlab.com/go-utilities/workerpool v0.1.0/go.mod h1:zvCpBW3Abv/khLW76G7BkjZR8Hmtt28GIU9hAUyUq2M=
2840
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
29-
golang.org/x/sys v0.0.0-20220818161305-2296e01440c6 h1:Sx/u41w+OwrInGdEckYmEuU5gHoGSL4QbDz3S9s6j4U=
30-
golang.org/x/sys v0.0.0-20220818161305-2296e01440c6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
41+
golang.org/x/sys v0.0.0-20220825204002-c680a09ffe64 h1:UiNENfZ8gDvpiWw7IpOMQ27spWmThO1RwwdQVbJahJM=
42+
golang.org/x/sys v0.0.0-20220825204002-c680a09ffe64/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
3143
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
3244
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
3345
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=

internal/smsync/cfg.go

+6-8
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
// SPDX-FileCopyrightText: 2018-2020 Michael Picht <[email protected]>
2-
//
3-
// SPDX-License-Identifier: GPL-3.0-or-later
4-
51
package smsync
62

73
// cfg.go implements the logic that is needed for the configuration
@@ -18,7 +14,9 @@ import (
1814
"time"
1915

2016
log "github.com/sirupsen/logrus"
21-
"gitlab.com/mipimipi/go-utils/file"
17+
"gitlab.com/go-utilities/file"
18+
fp "gitlab.com/go-utilities/filepath"
19+
2220
yaml "gopkg.in/yaml.v2"
2321
)
2422

@@ -156,8 +154,8 @@ func (cfg *Config) Get(init bool) error {
156154
// retrieved, a pointer to the cvm structure and true is returned, otherwise
157155
// nil and false
158156
func (cfg *Config) getCv(f string) (*cvm, bool) {
159-
if _, ok := cfg.Cvs[file.Suffix(f)]; ok {
160-
return cfg.Cvs[file.Suffix(f)], true
157+
if _, ok := cfg.Cvs[fp.Suffix(f)]; ok {
158+
return cfg.Cvs[fp.Suffix(f)], true
161159
}
162160
if _, ok := cfg.Cvs[suffixStar]; ok {
163161
return cfg.Cvs[suffixStar], true
@@ -177,7 +175,7 @@ func (cfg *Config) getExcludes(excls *[]string) {
177175
}
178176

179177
// expand directory
180-
a, err := filepath.Glob(file.EscapePattern(filepath.Join(cfg.SrcDir.Path(), excl)))
178+
a, err := filepath.Glob(fp.EscapePattern(filepath.Join(cfg.SrcDir.Path(), excl)))
181179
if err != nil {
182180
log.Errorf("Config.getExcludes: %v", err)
183181
return

internal/smsync/conversion.go

+3-6
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
// SPDX-FileCopyrightText: 2018-2020 Michael Picht <[email protected]>
2-
//
3-
// SPDX-License-Identifier: GPL-3.0-or-later
4-
51
package smsync
62

73
import (
@@ -12,7 +8,8 @@ import (
128
"time"
139

1410
log "github.com/sirupsen/logrus"
15-
"gitlab.com/mipimipi/go-utils/file"
11+
"gitlab.com/go-utilities/file"
12+
fp "gitlab.com/go-utilities/filepath"
1613
)
1714

1815
type (
@@ -120,7 +117,7 @@ func convert(cfg *Config, srcFile file.Info) cvOutput {
120117
cv = cp
121118
} else {
122119
// determine transformation function for srcSuffix -> trgSuffix
123-
cv = validCvs[cvKey{srcSuffix: file.Suffix(srcFile.Path()), trgSuffix: cvm.TrgSuffix}]
120+
cv = validCvs[cvKey{srcSuffix: fp.Suffix(srcFile.Path()), trgSuffix: cvm.TrgSuffix}]
124121
}
125122

126123
// execute conversion

internal/smsync/copy.go

+1-5
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
1-
// SPDX-FileCopyrightText: 2018-2020 Michael Picht <[email protected]>
2-
//
3-
// SPDX-License-Identifier: GPL-3.0-or-later
4-
51
package smsync
62

73
import (
84
"fmt"
95
"strings"
106

11-
"gitlab.com/mipimipi/go-utils/file"
7+
"gitlab.com/go-utilities/file"
128
)
139

1410
// implementation of interface "conversion" for simple file copy

internal/smsync/ffmpeg.go

+3-6
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
// SPDX-FileCopyrightText: 2018-2020 Michael Picht <[email protected]>
2-
//
3-
// SPDX-License-Identifier: GPL-3.0-or-later
4-
51
package smsync
62

73
// ffmpeg.go contains coding that is specific to the command line tool ffmpeg,
@@ -14,7 +10,8 @@ import (
1410
"path/filepath"
1511
"strings"
1612

17-
"gitlab.com/mipimipi/go-utils/file"
13+
"gitlab.com/go-utilities/file"
14+
fp "gitlab.com/go-utilities/filepath"
1815

1916
log "github.com/sirupsen/logrus"
2017
)
@@ -52,7 +49,7 @@ func execFFMPEG(srcFile string, trgFile string, params *[]string) error {
5249
}
5350

5451
// assemble error file name
55-
errFile := filepath.Join(errDir, filepath.Base(file.PathTrunk(trgFile))) + ".log"
52+
errFile := filepath.Join(errDir, filepath.Base(fp.PathTrunk(trgFile))) + ".log"
5653
// write stdout into error file
5754
if e := os.WriteFile(errFile, out, 0644); e != nil {
5855
log.Errorf("Couldn't write FFMPEG error file '%s's: %v", errFile, e)

internal/smsync/files.go

+11-14
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
// SPDX-FileCopyrightText: 2018-2020 Michael Picht <[email protected]>
2-
//
3-
// SPDX-License-Identifier: GPL-3.0-or-later
4-
51
package smsync
62

73
import (
@@ -11,8 +7,9 @@ import (
117
"time"
128

139
log "github.com/sirupsen/logrus"
14-
"gitlab.com/mipimipi/go-utils"
15-
"gitlab.com/mipimipi/go-utils/file"
10+
"gitlab.com/go-utilities/file"
11+
fp "gitlab.com/go-utilities/filepath"
12+
"gitlab.com/go-utilities/reflect"
1613
)
1714

1815
// errDir is the directory that stores error logs from conversion
@@ -32,14 +29,14 @@ func assembleTrgFile(cfg *Config, srcFile string) string {
3229
// if corresponding conversion rule is for '*' ...
3330
if cvm.TrgSuffix == suffixStar {
3431
// ... target suffix is same as source suffix
35-
trgSuffix = file.Suffix(srcFile)
32+
trgSuffix = fp.Suffix(srcFile)
3633
} else {
3734
// ... otherwise take target suffix from conversion rule
3835
trgSuffix = cvm.TrgSuffix
3936
}
4037

41-
trgFile, err := file.PathRelCopy(cfg.SrcDir.Path(),
42-
file.PathTrunk(srcFile)+"."+trgSuffix,
38+
trgFile, err := fp.PathRelCopy(cfg.SrcDir.Path(),
39+
fp.PathTrunk(srcFile)+"."+trgSuffix,
4340
cfg.TrgDir.Path())
4441
if err != nil {
4542
log.Errorf("Target path cannot be assembled: %v", err)
@@ -72,7 +69,7 @@ func deleteObsoleteFiles(cfg *Config, srcDir file.Info) {
7269
)
7370

7471
// assemble target directory path
75-
trgDir, err = file.PathRelCopy(cfg.SrcDir.Path(),
72+
trgDir, err = fp.PathRelCopy(cfg.SrcDir.Path(),
7673
srcDir.Path(),
7774
cfg.TrgDir.Path())
7875
if err != nil {
@@ -125,8 +122,8 @@ func deleteObsoleteFiles(cfg *Config, srcDir file.Info) {
125122
continue
126123
}
127124
// check if counterpart file on source side exists
128-
tr := file.PathTrunk(trgEntr.Name())
129-
fs, err := filepath.Glob(file.EscapePattern(filepath.Join(srcDir.Path(), tr)) + ".*")
125+
tr := fp.PathTrunk(trgEntr.Name())
126+
fs, err := filepath.Glob(fp.EscapePattern(filepath.Join(srcDir.Path(), tr)) + ".*")
130127
if err != nil {
131128
log.Errorf("deleteObsoleteFiles: %v", err)
132129
return
@@ -202,7 +199,7 @@ func GetSyncFiles(cfg *Config, init bool) (files *[]*file.Info) {
202199

203200
// if a directory is excluded, itself and all sub directories and
204201
// files are not relevant
205-
if utils.Contains(cfg.Excludes, srcFile.Path()) {
202+
if reflect.Contains(cfg.Excludes, srcFile.Path()) {
206203
return false, file.InvalidFromSuper
207204
}
208205
// if relevance is propagated from the parent, this directory is not
@@ -238,7 +235,7 @@ func GetSyncFiles(cfg *Config, init bool) (files *[]*file.Info) {
238235
log.Debug("Parent dir changed")
239236

240237
// assemble target directory
241-
trgDir, _ := file.PathRelCopy(cfg.SrcDir.Path(), srcFile.Path(), cfg.TrgDir.Path())
238+
trgDir, _ := fp.PathRelCopy(cfg.SrcDir.Path(), srcFile.Path(), cfg.TrgDir.Path())
242239
// check if target directory exists
243240
if exists, err := file.Exists(trgDir); err == nil && !exists {
244241
log.Debug("Trg doesn't exist -> FALSE, NONE FROM SUPER")

internal/smsync/flac.go

+2-7
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
// SPDX-FileCopyrightText: 2018-2020 Michael Picht <[email protected]>
2-
//
3-
// SPDX-License-Identifier: GPL-3.0-or-later
4-
51
package smsync
62

73
import (
@@ -10,9 +6,8 @@ import (
106
"strconv"
117
"strings"
128

13-
"gitlab.com/mipimipi/go-utils"
14-
159
log "github.com/sirupsen/logrus"
10+
s "gitlab.com/go-utilities/strings"
1611
)
1712

1813
// implementation of interface "conversion" for conversions to FLAC
@@ -26,7 +21,7 @@ func (cvAll2FLAC) exec(srcFile string, trgFile string, cvStr string) error {
2621
params = append(params, "-codec:a", "flac")
2722

2823
// set compression level
29-
params = append(params, "-compression_level", utils.SplitMulti(cvStr, "|:")[1])
24+
params = append(params, "-compression_level", s.SplitMulti(cvStr, "|:")[1])
3025

3126
// execute ffmpeg
3227
return execFFMPEG(srcFile, trgFile, &params)

internal/smsync/log.go

+1-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
// SPDX-FileCopyrightText: 2018-2020 Michael Picht <[email protected]>
2-
//
3-
// SPDX-License-Identifier: GPL-3.0-or-later
4-
51
package smsync
62

73
// log.go implements some wrapper functionality for logging
@@ -14,7 +10,7 @@ import (
1410
"strings"
1511

1612
log "github.com/sirupsen/logrus"
17-
"gitlab.com/mipimipi/go-utils/file"
13+
"gitlab.com/go-utilities/file"
1814
)
1915

2016
// LogFile is the log file. smsync always logs into ./smsync.log

0 commit comments

Comments
 (0)