Skip to content

Commit

Permalink
feat: create lock file after sync is finished (#9)
Browse files Browse the repository at this point in the history
  • Loading branch information
tleguijt authored Jan 15, 2025
1 parent b08f1bd commit 631a024
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
3 changes: 3 additions & 0 deletions .changes/unreleased/Changed-20250115-084936.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
kind: Changed
body: Create lock file after sync has finished instead of prior to sync
time: 2025-01-15T08:49:36.541465+01:00
14 changes: 8 additions & 6 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,18 +71,20 @@ var syncCmd = &cobra.Command{
}
}

// Perform the sync
err = internal.SyncDirectory(ctx, client, localDir, remoteDir, 20)
if err != nil {
log.Fatalf("directory sync failed: %v", err)
}
fmt.Println("Directory synchronized successfully; creating lock file")

// Create the lockfile (empty file)
err = client.UploadFile(ctx, strings.NewReader(""), filepath.Join(remoteDir, lockFile))
if err != nil {
log.Fatalf("failed to create lock file: %v", err)
}

// Perform the sync
err = internal.SyncDirectory(ctx, client, localDir, remoteDir, 20)
if err != nil {
log.Fatalf("directory sync failed: %v", err)
}
fmt.Println("Directory synchronized successfully.")
fmt.Println("Lock file", lockFile, "created. Sync process finished.")
},
}

Expand Down

0 comments on commit 631a024

Please sign in to comment.