private void cleanFilesUntilSpaceEnough() {
        File file = fileDirectoryFile;
        if (file.getUsableSpace() > minUsableSpaceBytes) {
            return;
        }
        int lastElementIndex = files.size() - 1;
        int i = 0;
        for (LogFile logFile : files) {
            if (i == lastElementIndex) {
                break;
            }
            deleteLogFile(logFile);
            if (file.getUsableSpace() > minUsableSpaceBytes) {
                return;
            }
            i++;
        }
        InternalLogger.INSTANCE.fatal("Freeze to wait for the space to be available");
        while (true) {
            try {
                // TODO: don't freeze other appenders
                Thread.sleep(1000L);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
            if (file.getUsableSpace() > minUsableSpaceBytes) {
                break;
            }
        }
        InternalLogger.INSTANCE.info("The space has become available");
    }
Note that it is fine to close file channel and open a new one not atomically because there is
always only one thread will call roll() and append()
turms-server-common/src/main/java/im/turms/server/common/infra/logging/core/appender/file/RollingFileAppender.java