Skip to content

Commit

Permalink
Merge pull request #40 from slytomcat/dev
Browse files Browse the repository at this point in the history
Correct spelling
  • Loading branch information
slytomcat authored Apr 16, 2024
2 parents 6ad8241 + a5e39ed commit 31083d9
Show file tree
Hide file tree
Showing 9 changed files with 26 additions and 25 deletions.
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
yd-go
yd-go*
icons/img/src
icons/img/*_.png
icons/img/*_.png
.vscode
8 changes: 4 additions & 4 deletions notify/notify.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@ const (
// The application is the name of application.
// The defaultIcon is icon name/path to be used for notification when no icon specified during the Send call.
// True value of replace means that a new notification will replace the previous one if it is still displayed.
// The time sets the time in milliseconds after which the notification will desappear. Set it to -1 to use default.
func New(application, defailtIcon string, replace bool, time int) (*Notify, error) {
// The time sets the time in milliseconds after which the notification will disappear. Set it to -1 to use default.
func New(application, defaultIcon string, replace bool, time int) (*Notify, error) {
conn, err := dbus.ConnectSessionBus()
if err != nil {
return nil, err
}
notify := &Notify{
app: application,
icon: defailtIcon,
icon: defaultIcon,
replace: replace,
time: time,
conn: conn,
Expand All @@ -47,7 +47,7 @@ func New(application, defailtIcon string, replace bool, time int) (*Notify, erro
return notify, nil
}

// Close closes d-bus connection. Call it on app exit or similar casess.
// Close closes d-bus connection. Call it on app exit or similar cases.
func (n *Notify) Close() {
n.conn.Close()
}
Expand Down
2 changes: 1 addition & 1 deletion notify/notify_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ func TestDBusNotify(t *testing.T) {
t.Skip("Skipping testing in CI environment")
}
icon := "dialog-information"
n, err := New("appname", "", true, -1)
n, err := New("appName", "", true, -1)
require.NoError(t, err)
require.NotNil(t, n)
defer n.Close()
Expand Down
6 changes: 3 additions & 3 deletions tools/tools.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func XdgOpen(uri string) error {

// MakeTitle returns the shorten version of its first parameter. The second parameter specifies
// the maximum number of symbols (runes) in returned string. It also replaces underscore symbol with
// the special unicode symbols sequense that looks very similar to the original underscore
// the special unicode symbols sequence that looks very similar to the original underscore
func MakeTitle(s string, l int) string {
r := []rune(s)
if len(r) < l {
Expand All @@ -49,14 +49,14 @@ func replaceUnderscore(s string) string {
return strings.ReplaceAll(s, "_", "\u2009\u0332\u2009") // thin space + combining low line + thin space
}

// Config is applicatinon configuration
// Config is application configuration
type Config struct {
path string // config file path
Conf string // path to daemon config file
Theme string // icons theme name
Notifications bool // display desktop notification
StartDaemon bool // start daemon on app start
StopDaemon bool // stop deemon on app exit
StopDaemon bool // stop daemon on app exit
}

// NewConfig returns the application configuration
Expand Down
4 changes: 2 additions & 2 deletions tools/tools_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,10 +155,10 @@ func TestAppInit(t *testing.T) {
t.Run("start with -h", func(t *testing.T) {
r, w, err := os.Pipe()
require.NoError(t, err)
oserr := os.Stderr
osErr := os.Stderr
os.Stderr = w
defer func() {
os.Stderr = oserr
os.Stderr = osErr
}()
// help request will call os.Exit(0) that panics the testing
require.Panics(t, func() { _, _ = AppInit(appName, []string{appName, "--help"}, "test") })
Expand Down
2 changes: 1 addition & 1 deletion yd.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ func onReady() {
m.about.Disable()
m.out.Disable()
m.notes.Disable()
// add meny warning
// add menu warning
systray.AddSeparator()
m.warning = systray.AddMenuItem(msg.Sprintf("Notification service unavailable!"), "")
} else {
Expand Down
8 changes: 4 additions & 4 deletions ydisk/ydisk.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ type YDvals struct {
Prog string // Synchronization progress (when in busy status)
}

/* A new YDvals constsructor */
/* A new YDvals constructor */
func newYDvals() YDvals {
return YDvals{
Stat: "unknown",
Expand Down Expand Up @@ -155,7 +155,7 @@ type watcher struct {
active bool // Flag that means that watching path was successfully added
}

func newwatcher() watcher {
func newWatcher() watcher {
watch, err := fsnotify.NewWatcher()
if err != nil {
log.Error("file_watcher", "error", err)
Expand Down Expand Up @@ -209,7 +209,7 @@ func NewYDisk(conf string, logger *slog.Logger) (*YDisk, error) {
if err != nil {
return nil, err
}
watch := newwatcher()
watch := newWatcher()
log.Debug("yandex-disk", "executable", exe)
yd := YDisk{
path,
Expand Down Expand Up @@ -269,7 +269,7 @@ func (yd *YDisk) eventHandler(watch watcher) {
log.Debug("change", "prev", yds.Prev, "new", yds.Stat,
"S", len(yds.Total) > 0, "L", len(yds.Last), "E", len(yds.Err) > 0)
yd.Changes <- yds
// in case of any change reset the timer intrval
// in case of any change reset the timer interval
interval = 1
}
}
Expand Down
12 changes: 6 additions & 6 deletions ydisk/ydisk_bench_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func BenchmarkYDvalUpdateString(b *testing.B) {
yd.update(st1)
}
}
func BenchmarkYDvalUpdatePrecomp(b *testing.B) {
func BenchmarkYDvalUpdatePreComp(b *testing.B) {
st1 := "Sync progress: 139.38 MB/ 139.38 MB (100 %)\nSynchronization core status: index\nPath to Yandex.Disk directory: '/home/stc/Yandex.Disk'\n\tTotal: 43.50 GB\n\tUsed: 2.89 GB\n\tAvailable: 40.61 GB\n\tMax file size: 50 GB\n\tTrash size: 0 B\n\nLast synchronized items:\n\tfile: 'NewFile'\n\tfile: 'File.ods'\n\tfile: 'downloads/file.deb'\n\tfile: 'downloads/setup'\n\tfile: 'download'\n\tfile: 'down'\n\tfile: 'do'\n\tfile: 'd'\n\tfile: 'o'\n\tfile: 'w'\n\n"
//st2 := "Synchronization core status: idle\nPath to Yandex.Disk directory: '/home/stc/Yandex.Disk'\n\tTotal: 43.50 GB\n\tUsed: 2.89 GB\n\tAvailable: 40.61 GB\n\tMax file size: 50 GB\n\tTrash size: 0 B\n\nLast synchronized items:\n\tfile: 'File.ods'\n\tfile: 'downloads/file.deb'\n\tfile: 'downloads/setup'\n\tfile: 'download'\n\tfile: 'down'\n\tfile: 'do'\n\tfile: 'd'\n\tfile: 'o'\n\tfile: 'w'\n\tfile: 'n'\n\n"
yd := newYDvals()
Expand All @@ -39,8 +39,8 @@ func BenchmarkYDvalUpdateOrig(b *testing.B) {
}
}

// func BenchmarkYDiskgetOutput(b *testing.B) {
// // prepare for similation
// func BenchmarkYDiskGetOutput(b *testing.B) {
// // prepare for simulation
// err := exec.Command(SymExe, "setup").Run()
// if err != nil {
// b.Fatal("simulation prepare error")
Expand Down Expand Up @@ -69,8 +69,8 @@ func BenchmarkYDvalUpdateOrig(b *testing.B) {
// }
// }

// func BenchmarkYDiskgetOutput2(b *testing.B) {
// // prepare for similation
// func BenchmarkYDiskGetOutput2(b *testing.B) {
// // prepare for simulation
// err := exec.Command(SymExe, "setup").Run()
// if err != nil {
// b.Fatal("simulation prepare error")
Expand Down Expand Up @@ -222,7 +222,7 @@ func (val *YDvals) update2(out string) bool {
return changed || val.ChLast
}

// precomppiled regexps
// precompiled regexps
func (val *YDvals) update1(out string) bool {
val.Prev = val.Stat // store previous status but don't track changes of val.Prev
changed := false // track changes for values
Expand Down
4 changes: 2 additions & 2 deletions ydisk/ydisk_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ func TestEmptyConf(t *testing.T) {
}

func TestFull(t *testing.T) {
// prepare for similation
// prepare for simulation
err := exec.Command(SymExe, "setup").Run()
require.NoError(t, err)
var YD *YDisk
Expand All @@ -100,7 +100,7 @@ func TestFull(t *testing.T) {
require.NoError(t, err)
})

t.Run("NotStartedOupput", func(t *testing.T) {
t.Run("NotStartedOutput", func(t *testing.T) {
output := YD.Output()
require.Empty(t, output)
})
Expand Down

0 comments on commit 31083d9

Please sign in to comment.