File size: 2,948 Bytes
ca28016
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
#!/bin/bash

echo "🚨 EMERGENCY CLEANUP SCRIPT FOR QWEN2GOLEM"
echo "=========================================="
echo ""
echo "⚠️  WARNING: This will delete backup files to free disk space"
echo "   Press Ctrl+C to cancel, or wait 5 seconds to continue..."
sleep 5

SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
cd "$SCRIPT_DIR/aether_mods_and_mems"

# Step 1: Remove old backup files (keeping only the latest)
echo ""
echo "πŸ“¦ Step 1: Removing old backup files..."
echo "----------------------------------------"

# List backups by size
echo "Current backup files:"
ls -lh *.backup_* 2>/dev/null | head -10

# Keep only the newest backup, remove others
if ls *.backup_* 1> /dev/null 2>&1; then
    # Get the newest backup file
    NEWEST_BACKUP=$(ls -t *.backup_* 2>/dev/null | head -1)
    echo "Keeping newest backup: $NEWEST_BACKUP"
    
    # Remove all other backups
    for file in *.backup_*; do
        if [ "$file" != "$NEWEST_BACKUP" ]; then
            echo "  Removing: $file ($(du -h "$file" | cut -f1))"
            rm -f "$file"
        fi
    done
else
    echo "No backup files found"
fi

# Step 2: Remove duplicate pattern files
echo ""
echo "πŸ“¦ Step 2: Removing duplicate pattern files..."
echo "----------------------------------------------"

# Remove checkpoint files older than 7 days
find . -name "*checkpoint*.json" -mtime +7 -exec rm -v {} \;

# Remove old conversation files
find . -name "gemini_golem_conversation_*.json" -mtime +7 -exec rm -v {} \;
find . -name "consciousness_discourse_*.json" -mtime +7 -exec rm -v {} \;

# Step 3: Compress large JSON files
echo ""
echo "πŸ“¦ Step 3: Compressing large JSON files..."
echo "------------------------------------------"

for file in *.json; do
    if [ -f "$file" ]; then
        SIZE=$(du -m "$file" | cut -f1)
        if [ "$SIZE" -gt 100 ]; then
            echo "  Compressing $file (${SIZE}MB)..."
            gzip "$file"
        fi
    fi
done

# Step 4: Clean temporary files
echo ""
echo "πŸ—‘οΈ  Step 4: Cleaning temporary files..."
echo "---------------------------------------"

# Remove log files older than 3 days
find "$SCRIPT_DIR" -name "*.log" -mtime +3 -exec rm -v {} \;

# Remove Python cache
find "$SCRIPT_DIR" -type d -name "__pycache__" -exec rm -rf {} + 2>/dev/null

# Remove .tmp files
find "$SCRIPT_DIR" -name "*.tmp" -exec rm -v {} \;

# Step 5: Show results
echo ""
echo "πŸ“Š CLEANUP RESULTS"
echo "=================="

# Show disk usage after cleanup
echo "Disk usage after cleanup:"
df -h /

# Show aether directory size
echo ""
echo "Aether directory size:"
du -sh "$SCRIPT_DIR/aether_mods_and_mems"

# Show memory status
echo ""
echo "Memory status:"
free -h

echo ""
echo "βœ… Cleanup complete!"
echo ""
echo "πŸ’‘ Additional recommendations:"
echo "   1. Consider moving old aether files to external storage"
echo "   2. Set up automatic cleanup to run weekly"
echo "   3. Limit pattern generation to prevent future buildup"