zyedidia / micro

A modern and intuitive terminal-based text editor
https://micro-editor.github.io
MIT License
24.93k stars 1.17k forks source link

Wipes the file and settings.json if disk is full. #3196

Open v972501 opened 6 months ago

v972501 commented 6 months ago

If disk is out of space and opening a file, micro wipes the file's content and it's settings.json file. Files still remain but their size is zero. No backups are created.

I have little disk space frequently so as a work-around I now launch micro through a small check script:

#!/bin/bash
echo "Checking disk space available..."
THRESHOLD_BYTES=$((50 * 1024 * 1024))
available_space=$(df --output=avail -B1 / | tail -n 1)

if [ "$available_space" -lt "$THRESHOLD_BYTES" ]; then
    echo "Error: Not enough disk space available. Aborting."
    exit 1
fi
echo "OK"
micro "$@"

OS: Debian Terminal: xfce4-terminal

dmaluka commented 6 months ago

Yes, it is a known major issue: #3148