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 { if !watchIgnoreClient {
log.Println(" [~] Starting Client Update Watcher") 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 { if watchIgnoreServer && watchIgnoreClient {

View file

@ -4,6 +4,7 @@ import (
"errors" "errors"
"github.com/darmiel/yaxc/internal/api" "github.com/darmiel/yaxc/internal/api"
"sync" "sync"
"time"
) )
var ( var (
@ -16,6 +17,9 @@ type Check struct {
mu sync.Mutex mu sync.Mutex
path string path string
pass string pass string
//
previousClipboard string
lastUpdate time.Time
} }
func NewCheck(path, pass string) *Check { func NewCheck(path, pass string) *Check {

View file

@ -2,7 +2,6 @@ package client
import ( import (
"github.com/atotto/clipboard" "github.com/atotto/clipboard"
"github.com/darmiel/yaxc/internal/common"
"log" "log"
"strings" "strings"
"time" "time"
@ -43,22 +42,10 @@ func (c *Check) CheckClient() (err error) {
return return
} }
// calculate hash if c.previousClipboard == cb {
var ch string
if ch = common.MD5Hash(cb); ch == "" {
err = ErrEmptyHash
return return
} }
c.previousClipboard = cb
// get hash from server
var sh string
sh, _ = c.a.GetHash(c.path)
if strings.TrimSpace(sh) != "" {
// compare hashes
if ch == sh {
return
}
}
// upload to server // upload to server
err = c.a.SetContent(c.path, c.pass, cb) err = c.a.SetContent(c.path, c.pass, cb)