fix: DB sync, upload reliability, parallel uploads, and sticker bug#28
Open
AjayaDahal wants to merge 33 commits into
Open
fix: DB sync, upload reliability, parallel uploads, and sticker bug#28AjayaDahal wants to merge 33 commits into
AjayaDahal wants to merge 33 commits into
Conversation
The ManageUploadsViewModel was deleting all remote_photos records older than 24 hours every time the Uploads screen was opened. This caused imported/restored cloud photo records to be immediately wiped.
Adds deduplicateDatabase() to BackupHelper that: - Removes duplicate remoteIds in remote_photos (keeps first) - Removes duplicate localIds in photos (keeps the one with remoteId) - Only deletes when 100% certain of duplication - Runs automatically after every database import - Logs results for debugging
- Set disableContentTypeDetection=true in sendDocument call (Telegram was auto-converting small/square images to stickers) - Added sticker response handling in sendFileApi as fallback - Photos that previously uploaded as stickers weren't getting remoteId tracked, causing infinite re-upload loop
After completing a batch of 50 uploads, the worker now checks if there are still pending photos and re-enqueues itself. Previously it would stop after one batch and wait for the daily periodic schedule.
- Worker now emits totalDone/totalPhotos in setProgress() - ViewModel reads batch progress + overall counts for Background uploads - New UploadProgressBar composable (Material3, animated, reusable) - MainPage shows backup progress bar above photo grid during uploads - ManageUploads shows richer progress text (batch + overall counts)
ExistingWorkPolicy.KEEP prevents new work from being enqueued when work with the same name already exists in a terminal state. Changed to REPLACE so the worker can successfully re-enqueue itself after completing each batch of 50 uploads.
…ctive worker Progress bar now visible on home page as long as there are un-uploaded photos, even between worker batch runs. Shows overall progress like '7,608 of 9,565 backed up'.
Adds a FAB share button (bottom-right) when viewing photos in full screen. Uses Android's share intent system to share via Messenger, SMS, WhatsApp, or any other installed app.
Shows a progress card above Active section with: - Linear progress bar for current batch - Remaining photo count - Current filename being uploaded - Visible whenever photos are pending
…rompt - Snapshot photo list when pager opens so background uploads don't shift the currently viewed photo - Cloud photos prompt 'Download first' when trying to share
Card-style progress bar with cloud icon, batch progress (Uploading X of 50), remaining count, and photo ID - identical layout to Uploads screen.
Cloud photos are now downloaded to cache dir on share tap, then shared via FileProvider URI. Shows 'Preparing to share...' toast while downloading. No more 'Download first' error.
Replaced UploadProgressBar composable with exact same inline code from ManageUploadsScreen - reads WorkManager directly, shows thumbnail, batch progress, and remaining count.
MainActivity.onCreate now checks for pending uploads and automatically enqueues the PeriodicBackup worker. Previously uploads would only start on manual button press or worker self-re-enqueue.
Comprehensive plan covering: - Laptop server architecture (FastAPI + ML) - Photo organization (timeline, people, places, years) - Face detection/recognition (InsightFace) - Semantic search (CLIP embeddings) - Server-phone sync protocol - Database schema design - 5-phase implementation plan
Server is local-only development. Bot tokens and configs must never be in the repo.
Server (Docker): - Phase 1-6: EXIF, Face Detection, Places, Search/Albums, Dashboard, Thumbnails - Metadata export: generates metadata.db and pushes to Telegram - Face detection with Python 3.12 compatibility fix - Auto-push metadata every 30 min App: - Local thumbnail DB (zero-network grid scrolling) - ThumbnailSyncWorker: parallel download, newest-first - Amazon Photos-style grid UX (smart dates, 2dp gaps, 4dp corners) - Full-screen preview: zoom, download, share, delete - Server discovery + hybrid mode - Metadata sync from Telegram (People, Places) - People and Places screens - Fixed DJI upload crash (image/jpg mime type) - Fixed progress bar stale data - Cleartext HTTP for local server - Aggressive paging (200 per page)
- Mark undecidable thumbnails (HEIC) as synced to stop retrying - Use itemCount instead of itemSnapshotList for layout cache trigger (prevents rebuilding grid on every thumbnail sync update)
Root cause: createRemoteLayoutCache called cloudPhotos[i] from Dispatchers.Default, but LazyPagingItems can only be accessed from the main thread. This silently broke paging after ~200 items. Fix: snapshot all items on main thread first, then process layout on background thread using the snapshot data.
LazyPagingItems must be accessed from main thread only. Previous approach used Dispatchers.Default which silently broke paging.
The grid was using currentLayoutItems.size which was capped at however many items the layout cache had built. Now uses cloudPhotos.itemCount directly so the grid knows about ALL items and can trigger paging properly. Falls back to direct paging access for items not yet in the layout cache.
- Paging trigger now loops with 500ms interval until all pages loaded - Added getAllLightFlow (excludes thumbnailBytes BLOB) for memory efficiency - Grid uses cloudPhotos.itemCount with fallback rendering
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes 3 major bugs reported by users:
Changes
Bug Fixes
ManageUploadsViewModelwas deleting all remote photo records older than 24h on every screen opendisableContentTypeDetection=trueso Telegram doesn't auto-convert small images to stickers (which broke remoteId tracking → infinite re-upload loop)getUpdates()call (only returns 24h of unprocessed updates) with upload-time tracking as source of truthSyncDbMediaStoreWorkerno longer deletes photos from DB if they have a cloud backupPerformance Improvements
copyTo()instead ofreadBytes()into memorydelete()instead ofdeleteOnExit()New Features
Testing