zyedidia / micro

A modern and intuitive terminal-based text editor

Home Page:https://micro-editor.github.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

v972501 opened this issue · comments

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

Yes, it is a known major issue: #3148