Commit Graph

1565 Commits

Author SHA1 Message Date
Cursor Agent
3487c90f1c Merge branch 'main' into windows-build
Resolved conflict in core/src/infra/sync/hlc.rs by adopting the main branch's
improved test implementation that properly uses FakeTimeSource for deterministic
time control in tests.
2026-01-03 21:53:34 +00:00
Jamie Pine
322db65663 feat(logo): replace ASCII logo with a dynamic purple orb rendering
- Removed the static ASCII logo and implemented a new function to calculate brightness on a sphere, allowing for a dynamic rendering of the Spacedrive logo as a purple orb using ANSI colors and Unicode half-blocks.
- Enhanced the `print_logo_colored` function to utilize the new brightness calculation and color gradient, improving visual representation.
- Updated related documentation to reflect the changes in logo rendering.
2025-12-31 16:46:58 -08:00
Jamie Pine
6b8f178788 refactor(tests): enhance debug output formatting in indexing tests
- Updated debug print statements in the indexing test to use consistent formatting with multi-line syntax for improved readability.
- Rearranged test suite definitions in `test_core.rs` for better organization and clarity, including renaming test cases for consistency.
- Added new test cases to cover additional functionalities, ensuring comprehensive test coverage.

These changes aim to improve the clarity of debug information and the overall structure of the test suite.
2025-12-31 16:46:50 -08:00
Jamie Pine
d9f0a4de5e fix(tests): improve Windows test stability and directory handling
- Reduced sleep duration after shutdown to 500ms to expedite test execution while still allowing time for SQLite file locks to release.
- Enhanced uniqueness of temporary directory names on Windows by incorporating a timestamp alongside a counter, preventing conflicts with leftover files from previous runs.
- Implemented retry logic for cleaning up leftover directories on Windows, improving robustness against file lock issues during test execution.

These changes aim to enhance the reliability and performance of tests in a Windows environment.
2025-12-31 13:44:25 -08:00
Jamie Pine
edf22c56d9 feat(indexing): enhance DatabaseAdapter and ChangeDetector to support device_id
- Added device_id parameter to DatabaseAdapter and DatabaseAdapterForJob for improved context handling.
- Updated ChangeDetector to utilize device_id when creating persistence instances, ensuring accurate indexing behavior.
- Refactored related tests to verify correct parent-child relationships and prevent duplicate entries during folder moves.
2025-12-31 12:54:58 -08:00
Jamie Pine
32e7fe9ca1 fix(tests): enhance Windows compatibility and test stability
- Normalize file paths to use forward slashes in Git pattern matching for better compatibility across platforms.
- Introduce a random suffix to temporary directory names in tests on Windows to avoid file lock contention during parallel execution.
- Add a delay after shutdown in tests to ensure SQLite file locks are released properly on Windows.

These changes aim to improve the reliability and consistency of tests in a Windows environment.
2025-12-31 12:45:22 -08:00
Brendan Allan
961ecdc657 formatting 2025-12-31 14:39:37 +08:00
Brendan Allan
48b986652c hlc time source 2025-12-31 14:37:11 +08:00
Jamie Pine
9f404225a6 Merge branch 'windows-build' of https://github.com/spacedriveapp/spacedrive into windows-build 2025-12-30 22:12:01 -08:00
Jamie Pine
710062b869 fix(windows): improve test stability and Windows API usage
- Fix flaky HLC test by handling timing variations between sequential calls
- Move GENERIC_READ import to correct module in Windows file operations
- Add debug logging to change detection test for troubleshooting

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 (1M context) <noreply@anthropic.com>
2025-12-30 22:11:27 -08:00
Jamie Pine
ff25fab772 refactor(tests): enhance fixture generation and update test suite structure
- Updated the fixture generation process to write to a temporary directory by default, improving test isolation and following best practices.
- Added instructions for regenerating source fixtures when needed, enhancing developer experience.
- Refactored the test suite structure to utilize a more flexible argument handling mechanism, allowing for easier addition of new tests.
- Removed deprecated test configurations and streamlined the test suite definitions for clarity and maintainability.
2025-12-30 22:06:53 -08:00
Jamie Pine
cc252c0fbc fix(windows): update imports in database_storage and local backend for clarity
- Added GENERIC_READ import directly in both database_storage.rs and local.rs to enhance clarity in Windows API usage.
- Ensured consistency in handling Windows-specific functionality across the codebase.
2025-12-30 17:30:28 -08:00
Jamie Pine
577133a4ed fix(dependencies): refine windows-sys features and improve usage in database_storage and local backend
- Removed unnecessary feature from windows-sys dependency to streamline functionality.
- Updated imports in database_storage.rs and local.rs to include GENERIC_READ directly, enhancing clarity and correctness in Windows API usage.
2025-12-30 17:05:50 -08:00
Jamie Pine
3ce614c7a6 fix(dependencies): update windows-sys features and improve null pointer handling
- Added "Win32_System_SystemServices" and "Win32_Security" features to the windows-sys dependency for enhanced functionality on Windows.
- Updated null pointer handling in database_storage.rs and local.rs to use std::ptr::null_mut() and 0 for better clarity and correctness.
2025-12-30 16:52:40 -08:00
Jamie Pine
d255ef185e refactor(tests): implement TestDataDir and SnapshotManager for improved test data handling
- Introduced TestDataDir for managing test data directories with automatic cleanup and optional snapshot support, ensuring all test data is created in the system temp directory.
- Added SnapshotManager to facilitate capturing snapshots of test state for post-mortem debugging, with platform-specific storage locations.
- Updated various integration tests to utilize the new TestDataDir structure, enhancing consistency and determinism in test execution.
- Revised documentation to reflect new conventions for test data management and snapshot usage.
2025-12-30 15:50:07 -08:00
Jamie Pine
2881117e00 feat(tests): update testing paths for deterministic integration tests
- Modified test data paths in various integration tests to use the Spacedrive source code instead of user directories, ensuring consistent and deterministic test results across environments.
- Updated comments and documentation to reflect the new testing approach and clarify the purpose of using project source code for testing.
- Enhanced the GitHub Actions workflow to skip Rust toolchain setup on macOS self-hosted runners, assuming Rust is pre-installed.
2025-12-30 13:05:19 -08:00
Jamie Pine
eb8d83df6e fix: improve readability of environment variable retrieval in indexing harness
Refactored the environment variable retrieval logic for Windows to enhance clarity by adding additional line breaks. This change maintains the existing functionality while making the code easier to read and understand.
2025-12-30 12:08:53 -08:00
Jamie Pine
fee527536c Merge branch 'main' into windows-build 2025-12-30 12:08:41 -08:00
Jamie Pine
04723e6950 Merge pull request #2944 from slvnlrt/fix/net-01-path-validation
fix(security): prevent path traversal in P2P file transfers and deletions
2025-12-30 10:57:42 -08:00
Jamie Pine
a292cc31cc fix: resolve async/await issues in file transfer path validation
- Changed get_all_allowed_paths() to async to properly await library manager operations
- Changed is_path_allowed() to async and fixed RwLock held across await points
- Changed validate_path_access() to async for consistency
- Replaced blocking_read() and block_on() with proper async/await
- Clone RwLock data before await to ensure future is Send
- Updated all call sites to use .await
- Improved error logging with structured tracing

This fixes compilation errors where futures were not Send due to
RwLockReadGuard being held across await points, and prevents potential
deadlocks from blocking operations in async contexts.

Fixes the file_transfer_test which now passes successfully.
2025-12-30 10:50:30 -08:00
slvnlrt
59686730b3 fix(security): prevent path traversal in P2P file transfers and deletions
Add path validation to FileTransferProtocolHandler and FileDeleteProtocolHandler to prevent unauthorized file access during P2P operations.

- Add is_path_allowed() validation against registered Locations
- Add dynamic location lookup via CoreContext integration
- Add security regression tests for both protocols

Prevents malicious paired devices from reading/writing/deleting files outside registered library locations.
2025-12-29 20:56:39 +01:00
Cursor Agent
a59404f0c7 Fix: Improve Windows inode retrieval for directories
Co-authored-by: ijamespine <ijamespine@me.com>
2025-12-29 18:58:17 +00:00
Jamie Pine
c86fc53815 feat(core): add documentation for Windows File ID tracking implementation
Introduces a new markdown file detailing the implementation of Windows File ID support for stable file identification across renames. This documentation outlines the problem with current Windows file handling, the solution using NTFS File IDs, and the expected user impact. It also includes acceptance criteria, implementation plans, known limitations, and success metrics, ensuring comprehensive guidance for developers.

Additionally, updates the indexing rules to include macOS metadata files in the system file rejection list, enhancing cross-platform compatibility.

Addresses task CORE-015.
2025-12-29 10:07:14 -08:00
Jamie Pine
0402fb05d1 feat(windows): implement NTFS File ID tracking for stable file identity
Implements Windows File ID support in the indexer to enable stable file
identification across renames on Windows NTFS filesystems. This brings
Windows to feature parity with Unix/Linux/macOS for change detection
and UUID persistence.

**Problem:**
Previously, Windows files didn't have stable identifiers across renames
because get_inode() returned None. This meant:
- Renamed files were treated as delete + create
- UUIDs were not preserved across renames
- Tags, metadata, and relationships were lost
- Files had to be re-indexed and re-hashed unnecessarily

**Solution:**
Uses Windows NTFS File IDs (64-bit file index) via GetFileInformationByHandle
API as the equivalent of Unix inodes for stable file identification.

**Changes:**
- Added windows-sys dependency for Win32 File System API access
- Implemented get_inode() for Windows using GetFileInformationByHandle
- Combines nFileIndexHigh and nFileIndexLow into 64-bit identifier
- Gracefully handles FAT32/exFAT (returns None) and permission errors
- Updated all call sites to pass both path and metadata parameters
- Updated test harness to verify Windows File ID tracking

**Benefits:**
- File renames now detected as moves (not delete + create)
- UUIDs preserved across renames within a volume
- Tags and metadata preserved across renames
- No re-indexing or re-hashing needed for renamed files

**Limitations:**
- Only works on NTFS (FAT32/exFAT fall back to path-only matching)
- File IDs are volume-specific (cross-volume copies get new UUIDs)

Addresses task CORE-015

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 (1M context) <noreply@anthropic.com>
2025-12-29 09:49:08 -08:00
Jamie Pine
da5e55e365 convert some repetitive info logs to debug 2025-12-29 07:33:28 -08:00
Jamie Pine
13a2b2e857 fix: address PR review feedback for PULL transfers
- Sanitize remote filename to prevent path traversal attacks
- Distinguish EOF vs actual errors when reading from stream
- Fail transfer on byte count mismatch instead of just logging
- Validate transfer_completed after loop to catch interrupted transfers
- Warn when checksum verification enabled but no checksum provided
- Remove redundant contains('..') check after canonicalize()
- Update comments for clarity
2025-12-26 12:47:43 -08:00
Jamie Pine
5c1c8dea88 feat(core): implement bidirectional remote file copy (PULL support)
Extends the FileCopyJob to support PULL operations, enabling files to be
copied FROM remote devices TO the local device. Previously, only PUSH
operations worked (local -> remote).

Changes:
- Add PullRequest/PullResponse messages to FileTransferMessage enum
- Add TransferDirection enum to detect PUSH vs PULL operations
- Refactor RemoteTransferStrategy to detect direction automatically
- Implement execute_pull() for remote source -> local destination
- Add handle_pull_request() handler on the protocol side
- Add path validation for security (prevent directory traversal)
- Add integration test for PULL operations

The strategy automatically detects direction based on SdPath:
- Source is local + Destination is remote = PUSH (existing behavior)
- Source is remote + Destination is local = PULL (new behavior)

This enables users to drag files from remote device explorers to local
folders, which previously failed with 'Source must be local path' error.

Closes FILE-005
2025-12-26 12:38:49 -08:00
Jamie Pine
996df041a4 Enhance file querying and alternate instances handling
- Updated `FileByIdQuery` and `FileByPathQuery` to populate alternate paths for files with the same content ID, improving data retrieval for file instances.
- Introduced `get_alternate_paths` method in both queries to fetch alternate file paths from the database.
- Modified the `InstancesTab` component to utilize a new query for alternate instances, enhancing the user interface with detailed instance information.
- Updated TypeScript types to support the new alternate instances query structure, ensuring type safety across the application.
- Adjusted various components to improve the display of alternate file instances, including device and path information.
2025-12-26 11:20:01 -08:00
Jamie Pine
8d0ae5065f Enhance FileSearchOutput structure and update search query logic
- Added a new `files` field to `FileSearchOutput` to provide a flat array of files, improving integration with the explorer.
- Updated the `FileSearchQuery` to join directory paths directly on `parent_id`, simplifying the SQL query.
- Enhanced the query to batch fetch sidecars for content UUIDs, improving performance and data retrieval.
- Adjusted the handling of content identity fields to ensure proper association with files in search results.
- Updated the `SearchView` component to utilize the new `files` array instead of the previous `results` structure.
2025-12-26 10:55:51 -08:00
Jamie Pine
c586544b0c Add device_id to entries for efficient querying
- Introduced a new column `device_id` in the entries table to denormalize device relationships, improving query performance.
- Updated related models and queries to accommodate the new device_id field.
- Enhanced foreign key mappings and migration scripts to support the addition of device_id.
- Adjusted various components to handle device_id, ensuring compatibility across the application.
- Improved release workflow to include specific file types for distribution.
2025-12-26 10:03:51 -08:00
Jamie Pine
f1547de0af Refactor file transfer protocol to skip encryption and decryption
- Updated `stream_file_data` to bypass encryption, as Iroh provides end-to-end encryption for connections.
- Adjusted `FileTransferProtocolHandler` to skip decryption, directly using the received encrypted data.
- Enhanced logging to reflect changes in data handling during file transfers.
- Added tests to ensure session keys are distinct and validate key swapping functionality.
- Improved error handling in `DevicePersistence` for corrupted session keys during device loading.
2025-12-25 22:33:21 -08:00
Jamie Pine
a313f2b9c8 Enhance file copy strategies and improve logging
- Updated documentation for copy strategies to clarify their use cases and selection logic.
- Improved logging in `DevicePersistence` to track loading of paired devices and handle expired session keys.
- Added detailed logging for session key retrieval in `FileTransferProtocolHandler`.
- Introduced a new test for file transfer with daemon restart to ensure session key persistence across restarts.
2025-12-25 15:46:36 -08:00
Jamie Pine
fd6a9122d6 Update submodule reference and enhance file copy job logging
- Updated macOS subproject reference to indicate a dirty state.
- Refactored `FileCopyJob` to improve logging for final destination calculations.
- Enhanced `stream_file_data` logging to include destination path in transfer requests.
- Added `find_containing` method to `EphemeralIndex` for substring search functionality.
- Improved logging in `ephemeral_search` to track search results and filtering.
- Replaced print statements with tracing logs in `FileTransferProtocolHandler` for better debugging.
2025-12-25 14:31:42 -08:00
Jamie Pine
1db5a0c491 Refactor filter application logic in ephemeral search function
- Adjusted indentation for clarity in the `search_ephemeral_index` function.
- Ensured consistent formatting for the filter application section to enhance code readability.
2025-12-25 13:14:10 -08:00
Jamie Pine
f7d38828b7 Merge branch 'main' into cursor/search-ui-integration-ephemeral-1978 2025-12-25 13:13:49 -08:00
Jamie Pine
7e23371c5d Refactor event handling in PersistentEventHandler to include periodic eviction ticks
- Replaced the previous event processing loop with a select-based approach to handle both incoming events and periodic eviction ticks.
- Ensured that expired pending removes are processed even when no new events arrive.
- Improved efficiency by reducing busy waiting during event collection.
2025-12-25 11:00:38 -08:00
Jamie Pine
bcaa1ff85c Implement directory preview and enhance file deletion testing
- Added `DirectoryPreview` component for rendering a grid view of subdirectories in the Quick Preview.
- Updated `ContentRenderer` to utilize `DirectoryPreview` for directory types.
- Introduced TypeScript integration test for verifying cache updates upon file deletions, ensuring accurate directory listing after deletions.
- Enhanced keyboard handling in Explorer to prevent shortcuts when input fields are focused.
2025-12-25 10:50:20 -08:00
Cursor Agent
98a342e974 feat: Implement search functionality and UI improvements
Co-authored-by: ijamespine <ijamespine@me.com>
2025-12-25 17:11:24 +00:00
Jamie Pine
b452871a67 feat: Integrate search UI with ephemeral and persistent indexes
Implements comprehensive search functionality that intelligently routes between
ephemeral (in-memory) and persistent (FTS5 database) indexes, following the
directory listing pattern for consistency.

**Backend Changes:**
- Add IndexType enum (Persistent/Ephemeral/Hybrid) to communicate which index was used
- Add FilterKind enum to indicate available filters for each search type
- Implement ephemeral_search module with content type filtering via FileTypeRegistry
- Update FileSearchOutput with index_type and available_filters fields
- Add routing logic in FileSearchQuery to determine and use appropriate index
- Support file type, size, date, and content type filters in ephemeral search

**Frontend Changes:**
- Add search mode to Explorer context (browse vs search with query/scope)
- Create SearchView component with placeholder for search results
- Wire up SearchBar with debounced search (300ms, min 2 chars)
- Integrate search mode switching in ExplorerView router

**Key Features:**
- Fast, synchronous search (no events, no jobs)
- Defaults to current folder scope (not global like Finder)
- Backend as source of truth for all search operations
- Content type filtering using FileTypeRegistry.identify_by_extension()
- Ephemeral search supports: file types, size, dates, content types
- Persistent search supports: all ephemeral filters + tags + locations

**Architecture:**
Follows the directory listing pattern: checks location index mode, queries
database, falls back to ephemeral cache. Search results indicate which index
was used and which filters are available for dynamic UI updates.
2025-12-25 08:59:51 -08:00
Jamie Pine
fdfa664cd9 Merge branch 'main' into feature/file-004-rename-and-folders 2025-12-25 08:30:50 -08:00
Jamie Pine
42b8e2c6f1 Update TODO list and enhance ThumbnailPolicy configuration
- Marked several tasks as completed in the TODO list, including opening files with the default app, drag selection area functionality, and initializing the startup screen for Core/daemon.
- Added `run_in_background` field to ThumbnailPolicy to control background execution behavior.
2025-12-25 08:20:36 -08:00
Jamie Pine
8d157325e1 Merge branch 'main' into feature/file-004-rename-and-folders 2025-12-25 08:13:40 -08:00
Cursor Agent
d4215df67a Apply cargo fmt to fix formatting 2025-12-25 16:05:27 +00:00
Cursor Agent
3f78b97495 Merge main into feature/file-004-rename-and-folders
Resolved conflicts in:
- SelectionContext.tsx: Merged rename state with isActiveTab prop
- useFileContextMenu.ts: Combined rename/folder actions with Open With submenu
- FileCard.tsx: Integrated InlineNameEdit with useOpenWith hook
- TableRow.tsx: Integrated InlineNameEdit with useOpenWith hook
2025-12-25 16:04:48 +00:00
Jamie Pine
5b02f5569f Enhance ThumbnailJobConfig to support background execution
- Updated ThumbnailJobConfig to include `run_in_background` field, allowing jobs to run without persisting to the database or updating the UI.
- Modified IndexerJob to inherit the background flag from its configuration.
- Implemented `should_persist` method in ThumbnailJob to determine persistence based on the background execution flag.
2025-12-25 08:00:32 -08:00
Jamie Pine
6bb6cb6c9a Enhance IndexerJobConfig to support background execution
- Added `run_in_background` field to `IndexerJobConfig` to allow jobs to run without persisting to the database or updating the UI.
- Updated `should_persist` method in `IndexerJob` to account for background jobs.
- Modified `handle_new_directory` in `DatabaseAdapter` to create background indexer jobs.
- Ensured default value for `run_in_background` is set to false in various configurations.
- Introduced a new integration test for bulk file moves to validate cache updates and file handling.
2025-12-25 07:30:07 -08:00
Jamie Pine
caf5a242fd Implement TypeScript integration tests with Rust bridge
- Added a new test suite in `core/tests/typescript_bridge_test.rs` to facilitate end-to-end testing between Rust and TypeScript.
- Introduced `IndexingHarnessBuilder` enhancements to support a daemon RPC server for TypeScript tests.
- Created TypeScript test files for `useNormalizedQuery` to validate file move and folder rename operations.
- Configured Bun test environment with `bunfig.toml` and setup scripts for improved testing efficiency.
- Updated `TcpSocketTransport` to handle TCP connections for the TypeScript client, ensuring robust communication with the Rust backend.
- Enhanced logging and error handling for better visibility during test execution.
2025-12-25 06:45:17 -08:00
Jamie Pine
1998975818 feat: Implement library validation and reset mechanism
- Added a new function `validate_and_reset_library_if_needed` to check if the current library exists and reset the state if it doesn't.
- Integrated this validation process into the daemon connection initialization, ensuring the app state is consistent with the available libraries.
- Enhanced error handling and logging for better debugging during library validation.
- Introduced a new test suite for file move operations, covering various scenarios to ensure robust handling of file movements and state integrity.
2025-12-25 05:39:36 -08:00
Jamie Pine
683714cb4a refactor: Update volume indexing process to use background task for job completion
- Replaced synchronous job completion handling with an asynchronous background task to improve responsiveness.
- Extracted job output handling and stats saving into the background task, allowing for better event-driven processing.
- Updated the `save_volume_stats` method to be static and adjusted the output structure to reflect the new indexing approach.
2025-12-25 02:43:32 -08:00
Jamie Pine
7f4b757290 Add comprehensive integration tests for the tag system
- Introduced a new test suite for validating the tag workflow, including tag creation, application, and database persistence.
- Implemented event collection to verify resource events during tag operations.
- Added assertions to ensure correct tag associations with files and proper database entries.
- Enhanced logging for better traceability of test execution and outcomes.
2025-12-24 10:00:58 -08:00