Merge Detection & Data Recovery¶
When scenes are merged in Stash, Peek automatically detects this and preserves your user activity data like watch history, ratings, and favorites.
How Scene Merging Works in Stash¶
In Stash, you can merge duplicate scenes together. This is useful when:
- You download a higher resolution version of a scene you already had
- You discover duplicates after adding new content
- You have alternate versions (director's cut, different endings)
When merging in Stash, the source scene is completely deleted - all its file fingerprints are transferred to the destination scene, but the source scene ID no longer exists.
The Problem Peek Solves¶
Without merge detection, when Peek syncs with Stash:
- Peek sees the source scene is missing from Stash
- Peek soft-deletes the source scene
- Your watch history, ratings, and favorites become "orphaned"
- When you view the merged (destination) scene, your activity data is missing
With merge detection, Peek automatically transfers your activity to the surviving scene.
Automatic Merge Detection¶
How It Works¶
Peek uses PHASH (perceptual hash) fingerprints to detect merges:
- When a scene is about to be soft-deleted during sync, Peek checks its PHASH
- If another scene has the same PHASH, it's likely a merge target
- Peek automatically transfers all user activity data to the target scene
- The source scene is then soft-deleted as normal
What Gets Transferred¶
For each user with activity on the merged scene:
| Data Type | Transfer Logic |
|---|---|
| Play count | Added together |
| Play duration | Added together |
| O count | Added together |
| Resume time | Target scene's value kept (if any) |
| Last played | Most recent timestamp kept |
| Rating | Target scene's rating kept (if set) |
| Favorite | OR logic - if either was favorited, result is favorited |
Automatic and Seamless
You don't need to do anything - merge detection happens automatically during normal syncs.
Admin Recovery Tool¶
For scenes that were merged before this feature was implemented, or where automatic detection couldn't find a match, admins can manually recover orphaned data.
Accessing the Tool¶
- Go to Settings (gear icon)
- Click the Server tab
- Select Merge Recovery
Understanding the Interface¶
The Merge Recovery tab shows:
- Total orphaned scenes with user activity
- For each orphan:
- Scene title and when it was deleted
- PHASH value (if available)
- Activity summary: total plays, ratings, favorites
- Potential PHASH matches
Recovering Orphaned Data¶
For a single scene:
- Click on an orphaned scene to expand it
- Review the potential matches (sorted by likelihood)
- Either:
- Click Transfer next to a match to transfer activity to that scene
- Enter a scene ID manually if you know the correct target
- The activity data is transferred and an audit record is created
For all scenes at once:
- Click Auto-Reconcile All
- Peek transfers activity for all orphans with exact PHASH matches
- Orphans without matches are skipped (handle manually later)
Discarding Orphaned Data¶
If an orphaned scene's data is no longer relevant (e.g., you deleted the scene intentionally):
- Expand the orphan
- Click Discard Activity
- Confirm the action
Permanent Action
Discarding orphaned data permanently deletes the watch history and ratings. This cannot be undone.
Limitations¶
When Automatic Detection Fails¶
PHASH-based detection may not work when:
- Scene had no PHASH - Fingerprinting wasn't run in Stash before the scene was synced to Peek
- Scene was deleted before PHASH sync - Peek didn't have the PHASH stored
- Scene was split, not merged - Different operation, same result in Peek
In these cases, use the admin recovery tool to manually reconcile.
PHASH Not Available¶
If a scene shows "No PHASH" in the recovery tool:
- The scene was synced before fingerprint syncing was implemented
- You can manually enter the target scene ID if you know it
- Future syncs will include PHASH data for new scenes
Audit Trail¶
Every merge reconciliation (automatic or manual) creates an audit record containing:
- Source and target scene IDs
- Which PHASH matched them (if automatic)
- All transferred data values
- When the reconciliation happened
- Who performed it (system for automatic, admin username for manual)
This ensures full traceability of data transfers.
Best Practices¶
Before Merging in Stash¶
- Run a full sync in Peek first to ensure PHASHes are stored
- Merge scenes in Stash as normal
- Run another sync - merge detection happens automatically
Checking Results¶
After a sync where merges occurred:
- Check the sync log for "Detected merge" messages
- Verify your watch history appears on the destination scene
- If something is missing, check the admin recovery tool
For Admins¶
- Periodically check the Merge Recovery tab for orphaned scenes
- Use Auto-Reconcile All to quickly process exact matches
- Manually review and reconcile scenes without PHASH matches
Troubleshooting¶
Activity Not Transferred¶
Possible causes:
- PHASH wasn't available at sync time
- Multiple potential matches exist (check admin tool)
- Scene was deleted, not merged
Solution: Use the admin recovery tool to manually reconcile.
Wrong Scene Got the Activity¶
If activity was transferred to the wrong scene:
- Currently, there's no automatic undo
- Contact your admin to manually adjust records if needed
- Future enhancement: undo capability using audit records
Orphaned Scenes Keep Appearing¶
If the same scenes keep showing as orphaned:
- They may have been deleted in Stash (not merged)
- Check if they should be discarded rather than reconciled
- If they're legitimately orphaned, use the recovery tool
Next Steps¶
- Watch History - Learn more about watch history tracking
- User Management - Admin features and user management