<commit_before>package org.yamcs.xtce;

import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.RandomAccessFile;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.yamcs.ConfigurationException;

/**
 * Abstract class for MDB loaders that load data from files (or directories with files)
 *  
 * @author nm
 *
 */
public abstract class AbstractFileLoader implements SpaceSystemLoader {
    protected final Logger log;
    protected String configName, path;
    
    
    public AbstractFileLoader(String path) throws ConfigurationException {
        this.path = path;
        this.configName=new File(path).getName()+"-"+path.hashCode();
        log=LoggerFactory.getLogger(getClass());
    }
    
    @Override
    public boolean needsUpdate(RandomAccessFile consistencyDateFile)  throws IOException, ConfigurationException {
        String line;
        while((line=consistencyDateFile.readLine())!=null) {
            if(line.startsWith(configName)) {
                File f=new File(path);
                if(!f.exists()) {
                    throw new ConfigurationException("The file "+path+" doesn't exist");
                }
                SimpleDateFormat sdf=new SimpleDateFormat("yyyy/DDD HH:mm:ss");
                try {
                    Date serializedDate=sdf.parse(line.substring(configName.length()+1));
                    if(serializedDate.getTime()>=f.lastModified()) {
                        log.debug("Serialized {} is up to date", configName);
                        return false;
                    } else {
                        log.debug("Serialized {} is NOT up to date: serializedDate={}, mdbConsistencyDate={}", configName, serializedDate, new Date(f.lastModified()));
                        return true;
                    }
                } catch (ParseException e) {
                    log.warn("Cannot parse the date from "+line+": ", e);
                    return true;
                }
            }
        }
        log.info("Could not find a line starting with 'MDB' in the consistency date file");
        return true;
    }
    
    @Override
    public void writeConsistencyDate(FileWriter consistencyDateFile) throws IOException {
        File f=new File(path);
        consistencyDateFile.write(configName+" "+(new SimpleDateFormat("yyyy/DDD HH:mm:ss")).format(f.lastModified())+"\n");
    }


    @Override
    public String getConfigName() throws ConfigurationException {
        return configName;
    }   
}<commit_msg>Use != instead of >= on date comparison check<commit_after>package org.yamcs.xtce;

import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.RandomAccessFile;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.yamcs.ConfigurationException;

/**
 * Abstract class for MDB loaders that load data from files (or directories with files)
 * 
 * @author nm
 *
 */
public abstract class AbstractFileLoader implements SpaceSystemLoader {
    protected final Logger log;
    protected String configName, path;

    public AbstractFileLoader(String path) throws ConfigurationException {
        this.path = path;
        this.configName = new File(path).getName() + "-" + path.hashCode();
        log = LoggerFactory.getLogger(getClass());
    }

    @Override
    public boolean needsUpdate(RandomAccessFile consistencyDateFile) throws IOException, ConfigurationException {
        String line;
        while ((line = consistencyDateFile.readLine()) != null) {
            if (line.startsWith(configName)) {
                File f = new File(path);
                if (!f.exists()) {
                    throw new ConfigurationException("The file " + path + " doesn't exist");
                }
                SimpleDateFormat sdf = new SimpleDateFormat("yyyy/DDD HH:mm:ss");
                try {
                    Date serializedDate = sdf.parse(line.substring(configName.length() + 1));
                    if (serializedDate.getTime() != f.lastModified()) {
                        log.debug("Serialized {} is up to date", configName);
                        return false;
                    } else {
                        log.debug("Serialized {} is NOT up to date: serializedDate={}, mdbConsistencyDate={}",
                                configName, serializedDate, new Date(f.lastModified()));
                        return true;
                    }
                } catch (ParseException e) {
                    log.warn("Cannot parse the date from " + line + ": ", e);
                    return true;
                }
            }
        }
        log.info("Could not find a line starting with 'MDB' in the consistency date file");
        return true;
    }

    @Override
    public void writeConsistencyDate(FileWriter consistencyDateFile) throws IOException {
        File f = new File(path);
        consistencyDateFile
                .write(configName + " " + (new SimpleDateFormat("yyyy/DDD HH:mm:ss")).format(f.lastModified()) + "\n");
    }

    @Override
    public String getConfigName() throws ConfigurationException {
        return configName;
    }
}
{'fraction_non_alphanumeric': 0.10197982816585731, 'fraction_numerical': 0.0011206574523720584, 'mean_word_length': 2.212357528494301, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 5, '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': '2403601', 'n_tokens_mistral': 1401, 'n_tokens_neox': 1344, 'n_words': 353}