fix: Add X-Tigris-Consistent headers and fix Windows rclone config path

- Add X-Tigris-Consistent: true headers to rclone commands for global strong consistency
- Fixes stale content reads for non-US users hitting Tigris edge cache
- Update get_rclone_config_path() to use runtime detection via rclone config file
- Supports Scoop, Chocolatey, and manual rclone installations on Windows
- Add tests for new headers and runtime config detection

Fixes #548

Co-authored-by: Paul Hernandez <phernandez@users.noreply.github.com>
This commit is contained in:
claude[bot]
2026-02-07 18:12:16 +00:00
parent 343a6e118b
commit d34c1cb2fa
4 changed files with 93 additions and 2 deletions
@@ -1,4 +1,7 @@
import subprocess
import time
from pathlib import Path
from unittest.mock import Mock
from basic_memory.cli.commands.cloud.bisync_commands import convert_bmignore_to_rclone_filters
from basic_memory.cli.commands.cloud.rclone_config import (
@@ -57,6 +60,38 @@ def test_convert_bmignore_to_rclone_filters_is_cached_when_up_to_date(config_hom
assert second.stat().st_mtime >= first_mtime
def test_get_rclone_config_path_uses_runtime_detection(monkeypatch, tmp_path):
"""Test that get_rclone_config_path uses rclone config file for runtime detection."""
config_path = tmp_path / "custom" / "rclone.conf"
def mock_run(cmd, **kwargs):
if cmd == ["rclone", "config", "file"]:
result = Mock()
result.returncode = 0
result.stdout = f"Configuration file is stored at:\n{config_path}"
return result
raise NotImplementedError(f"Unexpected command: {cmd}")
monkeypatch.setattr("subprocess.run", mock_run)
detected_path = get_rclone_config_path()
assert detected_path == config_path
assert detected_path.parent.exists()
def test_get_rclone_config_path_falls_back_on_error(monkeypatch):
"""Test that get_rclone_config_path falls back to default if rclone fails."""
def mock_run(cmd, **kwargs):
raise subprocess.SubprocessError("rclone not found")
monkeypatch.setattr("subprocess.run", mock_run)
fallback_path = get_rclone_config_path()
expected = Path.home() / ".config" / "rclone" / "rclone.conf"
assert fallback_path == expected
def test_configure_rclone_remote_writes_config_and_backs_up_existing(config_home):
cfg_path = get_rclone_config_path()
cfg_path.parent.mkdir(parents=True, exist_ok=True)
+12
View File
@@ -130,6 +130,9 @@ def test_project_sync_success(tmp_path):
assert "--filter-from" in cmd
assert str(filter_path) in cmd
assert "--dry-run" in cmd
assert "--header-download" in cmd
assert "X-Tigris-Consistent: true" in cmd
assert "--header-upload" in cmd
assert kwargs["text"] is True
@@ -214,6 +217,9 @@ def test_project_bisync_success(tmp_path):
assert "--compare=modtime" in cmd
assert "--workdir" in cmd
assert str(state_path) in cmd
assert "--header-download" in cmd
assert "X-Tigris-Consistent: true" in cmd
assert "--header-upload" in cmd
def test_project_bisync_requires_resync_first_time(tmp_path):
@@ -369,6 +375,9 @@ def test_project_check_success(tmp_path):
assert result is True
cmd, kwargs = runner.calls[0]
assert cmd[:2] == ["rclone", "check"]
assert "--header-download" in cmd
assert "X-Tigris-Consistent: true" in cmd
assert "--header-upload" in cmd
assert kwargs["capture_output"] is True
assert kwargs["text"] is True
@@ -407,6 +416,9 @@ def test_project_ls_success():
project = SyncProject(name="research", path="app/data/research")
files = project_ls(project, "my-bucket", run=runner, is_installed=lambda: True)
assert files == ["file1.md", "file2.md", "subdir/file3.md"]
cmd, _ = runner.calls[0]
assert "--header-download" in cmd
assert "X-Tigris-Consistent: true" in cmd
def test_project_ls_with_subpath():