3.3 KiB
""" Analysis: Export-Store vs Get-File cmdlet
=== FINDINGS ===
-
GET-FILE ALREADY EXISTS AND IS SUFFICIENT
- Located: cmdlets/get_file.py
- Purpose: Export files from any store backend to local path
- Usage: @1 | get-file -path C:\Downloads
- Supports: Explicit -path, configured output dir, custom filename
- Works with: All storage backends (Folder, HydrusNetwork, RemoteStorage)
-
ARCHITECTURE COMPARISON
GET-FILE (current): ✓ Takes hash + store name as input ✓ Queries backend.get_metadata(hash) to find file details ✓ For Folder: Returns direct Path from database ✓ For HydrusNetwork: Downloads to temp location via HTTP ✓ Outputs file to specified directory ✓ Supports both input modes: explicit (-hash, -store) and piped results
EXPORT-STORE (hypothetical): ✗ Would be redundant with get-file ✗ Would only work with HydrusNetwork (not Folder, Remote, etc.) ✗ No clear advantage over get-file's generic approach ✗ More specialized = less reusable
-
RECOMMENDED PATTERN
Sequence for moving files between stores:
search-store -store home | get-file -path /tmp/staging | add-file -storage test
This reads:
- Search Hydrus "home" instance
- Export matching files to staging
- Import to Folder "test" storage
-
FINDINGS ON THE @2 SELECTION ERROR
Debug output shows: "[debug] first-stage: sel=[1] rows=1 items=4"
This means:
- User selected @2 (second item, index=1 in 0-based)
- Table object had only 1 row
- But items_list had 4 items
CAUSE: Mismatch between displayed rows and internal items list
Possible reasons: a) Table display was incomplete (only showed first row) b) set_last_result_table() wasn't called correctly c) search-store didn't add all 4 rows to table object
FIX: Add better validation in search-store and result table handling
-
DEBUG IMPROVEMENTS MADE
Added to add_file.py run() method:
- Log input result type and length
- Show first item details: title, hash (truncated), store
- Log resolved source details
- Show validation failures with context
This will help debug "no items matched" errors in future
-
STORE FIELD IN RESULTS
Current behavior:
- search-store results show store="hydrus" (generic)
- Should show store="home" or store="work" (specific instance)
Next improvement:
- Update search-store to use FileStorage.list_backends() logic
- Use dynamic store detection like .pipe cmdlet does
- Show actual instance names in results table
=== RECOMMENDATIONS ===
-
DO NOT create export-store cmdlet
- get-file is already generic and works for all backends
- Adding export-store adds confusion without benefit
-
DO improve search-store display
- Import FileStorage and populate store names correctly
- Show "home" instead of "hydrus" when result is from Hydrus instance
- Similar to the .pipe cmdlet refactoring
-
DO fix the selection/table registration issue
- Verify set_last_result_table() is being called with correct items list
- Ensure every row added to table has corresponding item
- Add validation: len(table.rows) == len(items_list)
-
DO use the new debug logs in add_file
- Run: @2 | add-file -storage test
- Observe: [add-file] INPUT result details
- This will show if result is coming through correctly """