diff --git a/cmd/watch.go b/cmd/watch.go index f0f5e1d..0e3c4bc 100644 --- a/cmd/watch.go +++ b/cmd/watch.go @@ -49,7 +49,7 @@ var watchCmd = &cobra.Command{ if !watchIgnoreClient { log.Println(" [~] Starting Client Update Watcher") - go client.WatchClient(check, 100*time.Millisecond, done) + go client.WatchClient(check, 50*time.Millisecond, done) } if watchIgnoreServer && watchIgnoreClient { diff --git a/internal/client/client.go b/internal/client/client.go index 37417f8..4f61dee 100644 --- a/internal/client/client.go +++ b/internal/client/client.go @@ -4,6 +4,7 @@ import ( "errors" "github.com/darmiel/yaxc/internal/api" "sync" + "time" ) var ( @@ -16,6 +17,9 @@ type Check struct { mu sync.Mutex path string pass string + // + previousClipboard string + lastUpdate time.Time } func NewCheck(path, pass string) *Check { diff --git a/internal/client/watch_client.go b/internal/client/watch_client.go index 3c2602d..2902b6f 100644 --- a/internal/client/watch_client.go +++ b/internal/client/watch_client.go @@ -2,7 +2,6 @@ package client import ( "github.com/atotto/clipboard" - "github.com/darmiel/yaxc/internal/common" "log" "strings" "time" @@ -43,22 +42,10 @@ func (c *Check) CheckClient() (err error) { return } - // calculate hash - var ch string - if ch = common.MD5Hash(cb); ch == "" { - err = ErrEmptyHash + if c.previousClipboard == cb { return } - - // get hash from server - var sh string - sh, _ = c.a.GetHash(c.path) - if strings.TrimSpace(sh) != "" { - // compare hashes - if ch == sh { - return - } - } + c.previousClipboard = cb // upload to server err = c.a.SetContent(c.path, c.pass, cb)