Skip to content

Commit 59cda06

Browse files
committed
fix: don't redownload what we uploaded
1 parent 226a051 commit 59cda06

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

client/remote/client.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,7 @@ type Client struct {
455455
NewPullKey string
456456
NewPushKey string
457457
ReplicaID string
458-
Version string
458+
Version string // needs to stay string because it can be `latest`
459459
ReplicaPath string
460460
SetVisibility int
461461
KeyType string // "PUSH" or "PULL" - indicates the type of key being used
@@ -1508,7 +1508,7 @@ func (c *Client) GetReplicaID() string {
15081508
func (c *Client) GetReplicaPath() string {
15091509
return c.ReplicaPath
15101510
}
1511-
func (c *Client) GetVersion() string {
1511+
func (c *Client) GetLatestCommitVersion() string {
15121512
return c.Version
15131513
}
15141514
func (c *Client) GetKeyType() string {

client/sync/coordinator.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ func (c *Coordinator) executePullSubscribe() error {
298298
default:
299299
}
300300

301-
// Wait for new version notification
301+
// PULL (read only) Subscribe: Wait for new version notification
302302
for {
303303
if err := c.waitForVersionAndPull(false); err != nil {
304304
// Check if this is a cancellation or reconnection failure (both are terminal)
@@ -426,7 +426,7 @@ func (c *Coordinator) executePull(isSubscription bool) error {
426426
// Check database integrity after pull
427427
localClient.CheckIntegrity()
428428

429-
c.config.Version = remoteClient.GetVersion()
429+
c.config.Version = remoteClient.GetLatestCommitVersion()
430430
// Save pull result if needed
431431
if remoteClient.GetNewPullKey() != "" && c.authResolver.CheckNeedsDashFile(c.config.LocalPath, remotePath) {
432432
if err := c.authResolver.SavePullResult(
@@ -554,6 +554,7 @@ func (c *Coordinator) executePush() error {
554554

555555
// Perform the sync
556556
if err := c.performPushSync(localClient, remoteClient); err != nil {
557+
557558
// Check if this was a version conflict and auto-merge is enabled
558559
if remoteClient.HasVersionConflict() && c.config.AutoMerge {
559560
latestVersion := remoteClient.GetLatestVersion()
@@ -575,6 +576,8 @@ func (c *Coordinator) executePush() error {
575576
}
576577
}
577578

579+
c.config.Version = remoteClient.GetLatestCommitVersion()
580+
578581
// Save push result if we got new keys
579582
if remoteClient.GetNewPushKey() != "" {
580583
if err := c.authResolver.SavePushResult(
@@ -813,8 +816,6 @@ func (c *Coordinator) executePushSubscribe() error {
813816
return c.executePullSubscribe()
814817
}
815818

816-
fmt.Println("ℹ️ Change notifications will be sent to server for analytics")
817-
818819
// Create file watcher
819820
fileWatcher, err := watcher.NewWatcher(&watcher.Config{
820821
DatabasePath: c.config.LocalPath,
@@ -1380,7 +1381,6 @@ func (c *Coordinator) waitForVersionAndPull(isBackground bool) error {
13801381
return err
13811382
}
13821383

1383-
// Check if we already have this version
13841384
if c.config.Version == version {
13851385
if isBackground {
13861386
c.logger.Debug("Already at version, skipping pull", zap.String("version", version))

0 commit comments

Comments
 (0)