Files
Medios-Macina/ANALYSIS_export_store_vs_get_file.md

101 lines
3.3 KiB
Markdown
Raw Normal View History

2025-12-11 12:47:30 -08:00
"""
Analysis: Export-Store vs Get-File cmdlet
=== FINDINGS ===
1. 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)
2. 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
3. RECOMMENDED PATTERN
Sequence for moving files between stores:
search-store -store home | get-file -path /tmp/staging | add-file -storage test
This reads:
1. Search Hydrus "home" instance
2. Export matching files to staging
3. Import to Folder "test" storage
4. 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
5. 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
6. 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 ===
1. DO NOT create export-store cmdlet
- get-file is already generic and works for all backends
- Adding export-store adds confusion without benefit
2. 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
3. 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)
4. 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
"""