<commit_before>package peergos.user.fs;

import peergos.crypto.SymmetricKey;
import peergos.util.ByteArrayWrapper;
import peergos.util.Serialize;

import java.io.*;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

// The user side version of a metadatablob on the core node

public class Metadata
{
    public static final int MAX_ELEMENT_SIZE = Chunk.MAX_SIZE; //TODO restrict this
    public static enum TYPE {DIR, FILE, FOLLOWER}

    private final TYPE type;
    protected final byte[] encryptedMetadata;

    // public data
    private List<ByteArrayWrapper> fragments;

    public Metadata(TYPE t, byte[] encryptedMetadata)
    {
        this.type = t;
        this.encryptedMetadata = encryptedMetadata;
    }

    public Metadata(ChunkProperties props, SymmetricKey baseKey, byte[] iv) {
        type = TYPE.FOLLOWER;
        encryptedMetadata = baseKey.encrypt(props.serialize(), iv);
    }

    public void setFragments(List<ByteArrayWrapper> fragments) {
        this.fragments = fragments;
    }

    public List<ByteArrayWrapper> getFragmentHashes() {
        return Collections.unmodifiableList(fragments);
    }
<commit_msg>Ensure a NullPointerException is not thrown in this method if fragments is not initialized.<commit_after>package peergos.user.fs;

import peergos.crypto.SymmetricKey;
import peergos.util.ByteArrayWrapper;
import peergos.util.Serialize;

import java.io.*;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

// The user side version of a metadatablob on the core node

public class Metadata
{
    public static final int MAX_ELEMENT_SIZE = Chunk.MAX_SIZE; //TODO restrict this
    public static enum TYPE {DIR, FILE, FOLLOWER}

    private final TYPE type;
    protected final byte[] encryptedMetadata;

    // public data
    private List<ByteArrayWrapper> fragments;

    public Metadata(TYPE t, byte[] encryptedMetadata)
    {
        this.type = t;
        this.encryptedMetadata = encryptedMetadata;
    }

    public Metadata(ChunkProperties props, SymmetricKey baseKey, byte[] iv) {
        type = TYPE.FOLLOWER;
        encryptedMetadata = baseKey.encrypt(props.serialize(), iv);
    }

    public void setFragments(List<ByteArrayWrapper> fragments) {
        this.fragments = fragments;
    }

    public List<ByteArrayWrapper> getFragmentHashes() {
        if (fragments == null)
            return Collections.EMPTY_LIST;
        return Collections.unmodifiableList(fragments);
    }

{'fraction_non_alphanumeric': 0.08373397435897435, 'fraction_numerical': 0.0, 'mean_word_length': 3.5072202166064983, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4013817', 'n_tokens_mistral': 725, 'n_tokens_neox': 706, 'n_words': 200}