mirror of
https://github.com/darmiel/yaxc.git
synced 2025-09-05 22:14:25 +08:00
Removed unnecessary server-hash get
This commit is contained in:
parent
d04cc64c27
commit
0ce8fa2136
3 changed files with 7 additions and 16 deletions
|
@ -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 {
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Add table
Reference in a new issue