Skip to main content

Crate mimick

Crate mimick 

Source
Expand description

Handles application bootstrap, single-instance wiring, and daemon startup flow.

Initialises GTK/Libadwaita, registers the D-Bus application name for single-instance enforcement, and decides whether to present the library window or settings window based on user configuration. Background sync, tray icon, and filesystem monitor are wired up before entering the main event loop.

ModulesΒ§

api_client πŸ”’
Integrates with the Immich API, handles connectivity failover, and provides album/cache helpers.
app_context πŸ”’
Consolidated application context passed through the UI and background services.
autostart πŸ”’
Handles autostart integration for both native installations and sandboxed Flatpak builds.
cache_manager πŸ”’
Unified prune + clear over every on-disk cache subdirectory.
config πŸ”’
Handles persistent configuration loading and provides desktop keyring access helpers.
diagnostics πŸ”’
Exports a support-friendly diagnostics bundle with sensitive local data redacted for privacy.
library πŸ”’
Library view module – browse, search, and download assets from an Immich server.
logging πŸ”’
media_kinds πŸ”’
Central registry of supported media extensions, MIME types, and asset kinds.
monitor πŸ”’
Provides live filesystem monitoring, file-settling checks, and checksum generation.
notifications πŸ”’
Provides desktop notification helpers using the GIO notification portal.
profile πŸ”’
Per-profile state isolation driven by the MIMICK_PROFILE env var.
queue_manager πŸ”’
Manages upload queue orchestration, retry persistence, and sync-index updates.
remote_sync πŸ”’
Periodic remote-album reconciler.
runtime_env πŸ”’
Provides best-effort checks of system conditions to determine when uploads should be deferred.
sanitize πŸ”’
Input sanitisation for file paths and URLs.
settings_window πŸ”’
Implements the GTK4/Libadwaita settings window and status dashboard.
sidecar πŸ”’
XMP sidecar file discovery.
startup_scan πŸ”’
Performs a startup catch-up scan for files that were missed while Mimick was not running.
state_manager πŸ”’
Stores persistent status snapshots to restore basic UI state across application launches.
sync_index πŸ”’
Maintains a persistent index of files that have been previously synced.
tray_icon πŸ”’
Integrates StatusNotifier tray functionality and provides GTK-facing control signals.
util πŸ”’
Shared filesystem and I/O utilities.
watch_path_display πŸ”’
Provides user-friendly display names for watch paths.

StructsΒ§

UiFlags πŸ”’
Cross-thread UI requests: the tray task sets them and a GTK timer consumes them. Arc<Mutex<bool>> is Send + Sync, so the flags can cross into the tray’s Tokio task while the application handle itself stays on the GTK thread.

StaticsΒ§

APP_CONTEXT πŸ”’
Shared application context reused by UI entry points and the shutdown path.

FunctionsΒ§

api_key_missing πŸ”’
True until an API key is configured (or before the app context exists).
apply_runtime_preferences πŸ”’
build_api_client πŸ”’
API client for the enabled server URLs; warns when a URL is set without an API key.
build_queue_manager πŸ”’
Upload queue using the configured concurrency and pause policy (metered, battery, quiet hours).
command_line_context πŸ”’
consume_flag πŸ”’
Atomically check and clear a cross-thread boolean flag. Returns true if the flag was set, clearing it in the process.
find_window πŸ”’
Helper to look up active GTK window instances by widget name.
forward_tray_signal πŸ”’
Raise flag when the tray signal fired; false once the tray channel is closed.
handle_command_line πŸ”’
Handle command line from both the primary and secondary instances.
handle_local_deletion πŸ”’
Trash the remote copy of a locally deleted file, unless Mimick deleted it itself.
handle_ui_flags πŸ”’
Act on pending tray requests; returns Break after quitting to stop the timer.
init_logging πŸ”’
Mirror logs to stdout and to a rotating cache file for easier support/debugging.
install_termination_handler πŸ”’
Quit gracefully on SIGINT/SIGTERM, polling the signal flag from the GTK loop.
log_config πŸ”’
main πŸ”’
media_file_arguments πŸ”’
Collect file path arguments (positional args that are not flags) that Mimick can upload.
open_default_window πŸ”’
Open whichever window the user prefers, presenting an existing instance if available.
open_library_window_now πŸ”’
Open Library window, falling back to Settings if disabled.
open_settings_window_now πŸ”’
Open Settings window or present existing settings instance.
persist_on_shutdown πŸ”’
Persist final state and any pending retries on graceful shutdown.
poll_ui_flags πŸ”’
GTK-side: poll the flags every 250ms on the main thread. The application handle stays on the GTK thread and never enters Tokio tasks.
prepare_gtk πŸ”’
Desktop styling, global CSS, and the hold that keeps the app running without windows.
queue_ready_file πŸ”’
Queue a stable file for upload unless Mimick wrote it itself or it is already synced.
refresh_connection_status πŸ”’
Record the initial server route and any connection error for the status page.
restored_app_state πŸ”’
Load persisted state, resetting volatile fields that shouldn’t survive a restart.
run_catchup_scan πŸ”’
Queue anything in the watch folders that isn’t synced yet.
run_file_event_loop πŸ”’
Queue new files and mirror local deletions reported by the folder monitor.
run_manual_sync_listener πŸ”’
Run a catch-up scan for each β€œSync Now” request.
run_tray πŸ”’
Tokio-side: build the tray and forward its signals into the UI flags.
spawn_background_tasks πŸ”’
Start the file-event loop, catch-up scan, album reconciler, status check, and manual sync listener.
spawn_cache_prune πŸ”’
One-shot startup prune across every cache directory, delayed so it does not contend with window setup or initial sync work.
spawn_sync_index_flusher πŸ”’
Flush the sync index every 10s so a crash loses at most that much progress.
start_monitor πŸ”’
Keep the watcher service alive, but optionally disable active folder watches.
start_primary_instance πŸ”’
Set up config, API client, queue, monitor, tray, and background tasks. Runs only in the primary instance, from connect_startup.
upload_plan πŸ”’
(reassociate_only, checksum) for the queue, or None if the file is up to date.
wait_for_termination_signal πŸ”’
Wait for SIGINT or SIGTERM; false if a handler couldn’t be installed.
watch_target_for πŸ”’
Album target, watch root, rules, and library-only flag of the folder containing path.