<commit_before>package plow.libraries;

import java.io.File;

import javafx.application.Platform;

import org.eclipse.core.runtime.Path;

import plow.model.Playlist;
import plow.model.Track;

public class DirectoryScanner {

	public void synchronizeLibrary(final MusicLibrary lib) {
		final File folder = new File(lib.getLibrary());
		if (!folder.isDirectory()) {
			throw new RuntimeException("Not a valid library directory");
		}
		readAndSynchronize(lib, new File(lib.getLibrary()), "");
	}

	public void readAndSynchronize(final MusicLibrary lib, final File folder, final String prefix) {
		Playlist potentialPlaylist = null;
		for (final File f : folder.listFiles()) {
			final String filenameWithPrefix = ((prefix != "") ? prefix + Path.SEPARATOR : "") + f.getName();
			if (f.isDirectory()) {
				readAndSynchronize(lib, f, filenameWithPrefix);
			} else if (isTrackFile(f)) {
				if (!lib.getTracks().containsKey(filenameWithPrefix)) {
					final Track t = new Track(lib, prefix + Path.SEPARATOR, f.getName());
					t.setLastModified(f.lastModified());
					lib.addTrack(t);
					if (potentialPlaylist == null) {
						for (final Playlist p : lib.getPlaylists()) {
							if (p.getName().equals(prefix)) {
								potentialPlaylist = p;
							}
						}
					}
					if (potentialPlaylist == null) {
						potentialPlaylist = new Playlist();
						potentialPlaylist.setName(prefix);
						final Playlist addToPlaylist = potentialPlaylist;
						Platform.runLater(new Runnable() {
							@Override
							public void run() {
								lib.getPlaylists().add(addToPlaylist);
							}
						});

					}<commit_msg>ignore hidden files when scanning<commit_after>package plow.libraries;

import java.io.File;

import javafx.application.Platform;

import org.eclipse.core.runtime.Path;

import plow.model.Playlist;
import plow.model.Track;

public class DirectoryScanner {

	public void synchronizeLibrary(final MusicLibrary lib) {
		final File folder = new File(lib.getLibrary());
		if (!folder.isDirectory()) {
			throw new RuntimeException("Not a valid library directory");
		}
		readAndSynchronize(lib, new File(lib.getLibrary()), "");
	}

	public void readAndSynchronize(final MusicLibrary lib, final File folder, final String prefix) {
		Playlist potentialPlaylist = null;
		for (final File f : folder.listFiles()) {
			final String filenameWithPrefix = ((prefix != "") ? prefix + Path.SEPARATOR : "") + f.getName();
			if (f.isDirectory() && !f.isHidden()) {
				readAndSynchronize(lib, f, filenameWithPrefix);
			} else if (!f.isHidden() && isTrackFile(f)) {
				if (!lib.getTracks().containsKey(filenameWithPrefix)) {
					final Track t = new Track(lib, prefix + Path.SEPARATOR, f.getName());
					t.setLastModified(f.lastModified());
					lib.addTrack(t);
					if (potentialPlaylist == null) {
						for (final Playlist p : lib.getPlaylists()) {
							if (p.getName().equals(prefix)) {
								potentialPlaylist = p;
							}
						}
					}
					if (potentialPlaylist == null) {
						potentialPlaylist = new Playlist();
						potentialPlaylist.setName(prefix);
						final Playlist addToPlaylist = potentialPlaylist;
						Platform.runLater(new Runnable() {
							@Override
							public void run() {
								lib.getPlaylists().add(addToPlaylist);
							}
						});

					}
{'fraction_non_alphanumeric': 0.1278149726110773, 'fraction_numerical': 0.0, 'mean_word_length': 3.496580027359781, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '7046170', 'n_tokens_mistral': 1251, 'n_tokens_neox': 974, 'n_words': 232}