Removed unnecessary server-hash get

This commit is contained in:
darmiel 2021-03-28 16:33:51 +02:00
parent d04cc64c27
commit 0ce8fa2136
3 changed files with 7 additions and 16 deletions

View file

@ -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 {

View file

@ -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 {

View file

@ -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)