mirror of
https://github.com/rcourtman/Pulse.git
synced 2026-09-23 19:57:09 +00:00
fix: preserve .env file during automatic updates
- Backup .env file before git clean to prevent configuration loss - Restore .env file after git operations with proper ownership - Ensures user configuration survives cron-based updates 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -1047,10 +1047,36 @@ perform_update() {
|
||||
return 1
|
||||
fi
|
||||
|
||||
# Backup .env file before cleaning to preserve user configuration
|
||||
local env_backup_path=""
|
||||
if [ -f "$PULSE_DIR/.env" ]; then
|
||||
env_backup_path="/tmp/.env.backup.$$"
|
||||
print_info "Backing up .env file to preserve user configuration..."
|
||||
if cp "$PULSE_DIR/.env" "$env_backup_path"; then
|
||||
print_success ".env file backed up temporarily."
|
||||
else
|
||||
print_warning "Failed to backup .env file. Configuration may be lost."
|
||||
env_backup_path=""
|
||||
fi
|
||||
fi
|
||||
|
||||
print_info "Cleaning untracked files and directories..."
|
||||
if ! sudo -u "$PULSE_USER" git clean -fd; then
|
||||
print_warning "Failed to clean untracked files, continuing anyway."
|
||||
fi
|
||||
|
||||
# Restore .env file after cleaning
|
||||
if [ -n "$env_backup_path" ] && [ -f "$env_backup_path" ]; then
|
||||
print_info "Restoring .env file..."
|
||||
if cp "$env_backup_path" "$PULSE_DIR/.env"; then
|
||||
chown "$PULSE_USER":"$PULSE_USER" "$PULSE_DIR/.env"
|
||||
chmod 600 "$PULSE_DIR/.env"
|
||||
print_success ".env file restored successfully."
|
||||
else
|
||||
print_warning "Failed to restore .env file from backup."
|
||||
fi
|
||||
rm -f "$env_backup_path"
|
||||
fi
|
||||
|
||||
print_info "Fetching latest changes from git [running as user $PULSE_USER]..."
|
||||
if [ -n "$TARGET_TAG" ]; then
|
||||
|
||||
Reference in New Issue
Block a user