#!/usr/bin/env bash
# Push the wiki/, processing/, raw/ trees from your laptop to the VPS.
# First run: full sync (~minutes). Subsequent runs: only diffs (~seconds).
#
# Usage:  ./sync-data.sh

source "$(dirname "$0")/_lib.sh"
set -euo pipefail

LAPTOP_UFO_ROOT="${LAPTOP_UFO_ROOT:-/Users/guto/ufo}"

echo "→ Ensuring $VPS_DEPLOY_ROOT exists on VPS…"
vps_ssh "mkdir -p ${VPS_DEPLOY_ROOT}/{wiki,processing,raw}"

echo ""
echo "→ Syncing wiki/ → ${DATA_WIKI:-$VPS_DEPLOY_ROOT/wiki}"
vps_rsync "${LAPTOP_UFO_ROOT}/wiki/" "${DATA_WIKI:-$VPS_DEPLOY_ROOT/wiki}/"

echo ""
echo "→ Syncing processing/ → ${DATA_PROCESSING:-$VPS_DEPLOY_ROOT/processing}"
vps_rsync "${LAPTOP_UFO_ROOT}/processing/" "${DATA_PROCESSING:-$VPS_DEPLOY_ROOT/processing}/"

echo ""
echo "→ Syncing raw/ → ${DATA_RAW:-$VPS_DEPLOY_ROOT/raw}"
vps_rsync "${LAPTOP_UFO_ROOT}/raw/" "${DATA_RAW:-$VPS_DEPLOY_ROOT/raw}/"

echo ""
echo "✓ Data synced. Sizes on VPS:"
vps_ssh "du -sh ${VPS_DEPLOY_ROOT}/{wiki,processing,raw}"
