#!/bin/bash

# LibrePortal WebUI Update Lock Creation
# Creates update lock file to prevent concurrent updates

webuiCreateUpdateLock() {
    local lock_file="$containers_dir/libreportal/frontend/data/updater.lock"
    
    # Create lock file with timestamp and process ID. The lock lives in the
    # dockerinstall-owned WebUI data dir, so write it as the path owner.
    echo "LibrePortal WebUI Update: $(date '+%Y-%m-%d %H:%M:%S')" | runFileWrite "$lock_file"

    if [ $? -eq 0 ]; then
        isSuccessful "Update lock file created: $lock_file"
    else
        isNotice "Failed to create update lock file: $lock_file"
    fi
}
