private void checkCapacity(CapacityReader reader) throws IOException {
        if (null == reader) {
            return;
        }
        Long capacity = reader.capacity(this);
        if (null == capacity) {
            if (recoveryMode) {
                throw new WALNotInitializedException("try to open an uninitialized WAL in recovery mode: empty header. path: " + path);
            }
        } else if (capacityFact == CAPACITY_NOT_SET) {
            // recovery mode on block device
            capacityFact = capacity;
        } else if (capacityFact != capacity) {
            throw new WALCapacityMismatchException(path, capacityFact, capacity);
        }
        assert capacityFact != CAPACITY_NOT_SET;
    }
Create the file and set length if not exists, and check the file size if exists.
s3stream/src/main/java/com/automq/stream/s3/wal/util/WALBlockDeviceChannel.java