private void openExistingFile(LogFile existingFile) {
        ZonedDateTime now = existingFile.dateTime();
        ZonedDateTime next = now.plus(1, ChronoUnit.DAYS)
                .truncatedTo(ChronoUnit.DAYS);

        Path filePath = existingFile.path();

        channel = openFileChannel(filePath);
        currentFile = existingFile;

        try {
            nextFileBytes = channel.size();
        } catch (IOException e) {
            throw new InputOutputException(
                    "Failed to read the size of the file: "
                            + filePath,
                    e);
        }
        nextDay = TimeUnit.SECONDS.toNanos(next.toEpochSecond());
        nextIndex = existingFile.index() + 1;
    }
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