Expand description
Manages upload queue orchestration, retry persistence, and sync-index updates.
A configurable pool of async workers drains the upload queue in parallel. Failed tasks are moved to a retry queue with exponential back-off. The queue pauses automatically when environment policies (metered network, battery power, quiet hours) are active, and resumes when conditions clear.
Structsยง
- Batch
Notify ๐State - Environment
Policy - File
Task - Represents a unit of work for the upload queue.
- Queue
Manager
Functionsยง
- activate_
batch_ ๐if_ needed - add_
to_ ๐album_ with_ retry - apply_
active_ ๐state - apply_
idle_ ๐state - batch_
is_ ๐ready_ to_ notify - batch_
notification_ ๐summary - check_
batch_ ๐notification - clear_
stale_ ๐batch_ schedule - current_
attempt_ ๐count - Get current sync attempt count for a path based on recent events history.
- finalize_
upload_ ๐progress - Finalize upload progress: update counters, detect queue idle, return batch ID if a summary notification should be scheduled.
- handle_
upload ๐ - Upload or reassociate a file, then ensure the resulting asset is present in the target album.
- infer_
album_ ๐name - Infer target album name from directory structure segment.
- is_
quiet_ ๐hour - Returns true if the current local clock hour falls inside the configured quiet window.
- load_
retries ๐ - Load historical list of failed tasks from retries cache.
- record_
upload_ ๐failure - Record state updates after a failed upload.
- record_
upload_ ๐success - Activate a batch tracking window if none is currently active. Record state updates after a successful upload.
- resolve_
album_ ๐id - Resolve the album ID from either an explicit task ID or by name lookup.
- resolve_
final_ ๐asset_ id - save_
retries ๐ - Persist current list of failed items to retries cache.
- schedule_
batch_ ๐notification - Spawn a debounced batch-notification task.
- track_
consecutive_ ๐failures - Track consecutive failures and fire a connectivity-lost notification after 3+.
- unix_
timestamp_ ๐now - Return current epoch timestamp in seconds.
- upload_
progress_ ๐callback - Helper to generate progress callback callbacks that update global transfer metrics.
- wait_
until_ ๐allowed - Pause worker processing loops until environment checks and manual pauses permit resume.