#!/bin/bash # Targeted permission fix for specific folders only # This script affects ONLY the directories you're interested in echo "🎯 Fixing permissions for specific directories only..." echo "Target directories: Generated, static, view_session" echo "==================================================" # Check if directories exist first check_directory() { if [ -d "$1" ]; then current_perms=$(stat -f "%Mp%Lp" "$1" 2>/dev/null || stat -c "%a" "$1" 2>/dev/null) echo "📁 $1 - Current permissions: $current_perms" return 0 else echo "⚠️ $1 - Does not exist" return 1 fi } fix_directory_permissions() { if [ -d "$1" ]; then echo "🔧 Fixing permissions for: $1" # Fix directory permissions (755 = rwxr-xr-x) chmod 755 "$1" # Fix permissions for all contents recursively # Directories: 755, Files: 644 find "$1" -type d -exec chmod 755 {} \; 2>/dev/null find "$1" -type f -exec chmod 644 {} \; 2>/dev/null echo "✅ Fixed: $1" else echo "❌ Cannot fix: $1 (does not exist)" fi } echo "Current status:" check_directory ".cache/Generated" check_directory ".cache/static" check_directory ".cache/view_session" echo "" echo "Do you want to fix permissions for these directories? (y/N)" read -r response if [[ "$response" =~ ^[Yy]$ ]]; then echo "" echo "Applying permission fixes..." # Fix permissions for the actual directories in .cache fix_directory_permissions ".cache/Generated" fix_directory_permissions ".cache/static" fix_directory_permissions ".cache/view_session" echo "" echo "✅ Permission fix complete!" echo "" echo "Final status:" check_directory ".cache/Generated" check_directory ".cache/static" check_directory ".cache/view_session" else echo "Operation cancelled." fi