<commit_before>package hu.bme.mit.codemodel.rifle.actions.repository;

import java.io.File;
import java.io.IOException;
import java.util.Collection;

import hu.bme.mit.codemodel.rifle.database.DbServices;
import hu.bme.mit.codemodel.rifle.database.DbServicesManager;
import org.apache.commons.io.FileUtils;
import org.neo4j.driver.v1.Session;
import org.neo4j.driver.v1.Transaction;

/**
 * Synchronizes the database to the repository on a given path, branch and session.
 * <p>
 * Temporarily, this means only a recursive directory import without any incrementality.
 * Logic will be replaced with a filelist from a git diff.
 */
public class SynchronizeRepository {
    protected static final String[] extensions = new String[]{ "js" };

    protected final DbServices dbServices;

    protected final String path;
    protected final String branchId;
    protected final String sessionId;

    public SynchronizeRepository(String path, String branchId, String sessionId) {
        this.path = path;
        this.branchId = branchId;
        this.sessionId = sessionId;

        this.dbServices = DbServicesManager.getDbServices(this.branchId);
    }

    public void sync() {
        HandleChange handleChange = new HandleChange();
        Collection<File> files = FileUtils.listFiles(new File(path), extensions, true);

        try (Session session = dbServices.getDriver().session()) {
            try (Transaction tx = session.beginTransaction()) {
                for (File file : files) {
                    String contents = FileUtils.readFileToString(file);
                    handleChange.add(sessionId, file.getAbsolutePath(), contents, branchId, null, tx);
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
<commit_msg>Missing transaction commit<commit_after>package hu.bme.mit.codemodel.rifle.actions.repository;

import java.io.File;
import java.io.IOException;
import java.util.Collection;

import hu.bme.mit.codemodel.rifle.database.DbServices;
import hu.bme.mit.codemodel.rifle.database.DbServicesManager;
import org.apache.commons.io.FileUtils;
import org.neo4j.driver.v1.Session;
import org.neo4j.driver.v1.Transaction;

/**
 * Synchronizes the database to the repository on a given path, branch and session.
 * <p>
 * Temporarily, this means only a recursive directory import without any incrementality.
 * Logic will be replaced with a filelist from a git diff.
 */
public class SynchronizeRepository {
    protected static final String[] extensions = new String[]{ "js" };

    protected final DbServices dbServices;

    protected final String path;
    protected final String branchId;
    protected final String sessionId;

    public SynchronizeRepository(String path, String branchId, String sessionId) {
        this.path = path;
        this.branchId = branchId;
        this.sessionId = sessionId;

        this.dbServices = DbServicesManager.getDbServices(this.branchId);
    }

    public void sync() {
        HandleChange handleChange = new HandleChange();
        Collection<File> files = FileUtils.listFiles(new File(path), extensions, true);

        try (Session session = dbServices.getDriver().session()) {
            try (Transaction tx = session.beginTransaction()) {
                for (File file : files) {
                    String contents = FileUtils.readFileToString(file);
                    handleChange.add(sessionId, file.getAbsolutePath(), contents, branchId, null, tx);
                }

                tx.success();
            } catch (Exception e) {
                e.printStackTrace();
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

{'fraction_non_alphanumeric': 0.09503695881731784, 'fraction_numerical': 0.0021119324181626186, 'mean_word_length': 2.8118712273641853, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '4945821', 'n_tokens_mistral': 1037, 'n_tokens_neox': 992, 'n_words': 279}