<commit_before>using Gdk;
using Gtk;
using System.Collections;
using System.Collections.Generic;
using System;
using FSpot;
using FSpot.Utils;
using FSpot.Xmp;
using FSpot.UI.Dialog;
using System.IO;
using Mono.Unix;

public class ImportException : System.Exception {
	public ImportException (string msg) : base (msg)
	{
	}
}

public class FileImportBackend : ImportBackend {
	PhotoStore store;
 	RollStore rolls = FSpot.Core.Database.Rolls;
	TagStore tag_store = FSpot.Core.Database.Tags;
	bool recurse;
	bool copy;
	bool detect_duplicates;
	string [] base_paths;
	Tag [] tags;
	Gtk.Window parent;

	int count;
	int duplicate_count;
	XmpTagsImporter xmptags;

	ArrayList import_info;
	Stack directories;

	private class ImportInfo {
		string original_path;
		public string destination_path;
		public Photo Photo;
	       
		public string OriginalPath {
			get { return original_path; }
		}
		
		public string DestinationPath {
			get { return destination_path; }
			set { destination_path = value; }
		}
		
		public ImportInfo (string original)
		{
			original_path = original;
		        destination_path = null;
			Photo = null;
		}
	}
	
	private void AddPath (string path)
	{
		if (FSpot.ImageFile.HasLoader (path))
			import_info.Add (new ImportInfo (path));
	}

	private void GetListing (System.IO.DirectoryInfo info)
	{
		try {
			GetListing (info, info.GetFiles (), recurse);
		} catch (System.UnauthorizedAccessException) {
			System.Console.WriteLine ("Unable to access directory {0}", info.FullName);
		} catch (System.Exception e) {
			System.Console.WriteLine ("{0}", e.ToString ());
		}
	}

	private void GetListing (System.IO.DirectoryInfo dirinfo, System.IO.FileInfo [] files, bool recurse)
	{
		Log.Debug ("Scanning {0} for new photos", dirinfo.FullName);
		List<Uri> existing_entries = new List<Uri> ();

		foreach (Photo p in store.Query (new Uri (dirinfo.FullName)))
			foreach (uint id in p.VersionIds)
				existing_entries.Add (p.VersionUri (id));

		foreach (System.IO.FileInfo f in files)
			if (! existing_entries.Contains (UriUtils.PathToFileUri (f.FullName)) && !f.Name.StartsWith (".")) {
				AddPath (f.FullName);
			}

		if (recurse) {<commit_msg>Fix regression on importing same photo uris<commit_after>using Gdk;
using Gtk;
using System.Collections;
using System.Collections.Generic;
using System;
using FSpot;
using FSpot.Utils;
using FSpot.Xmp;
using FSpot.UI.Dialog;
using System.IO;
using Mono.Unix;

public class ImportException : System.Exception {
	public ImportException (string msg) : base (msg)
	{
	}
}

public class FileImportBackend : ImportBackend {
	PhotoStore store;
 	RollStore rolls = FSpot.Core.Database.Rolls;
	TagStore tag_store = FSpot.Core.Database.Tags;
	bool recurse;
	bool copy;
	bool detect_duplicates;
	string [] base_paths;
	Tag [] tags;
	Gtk.Window parent;

	int count;
	int duplicate_count;
	XmpTagsImporter xmptags;

	ArrayList import_info;
	Stack directories;

	private class ImportInfo {
		string original_path;
		public string destination_path;
		public Photo Photo;
	       
		public string OriginalPath {
			get { return original_path; }
		}
		
		public string DestinationPath {
			get { return destination_path; }
			set { destination_path = value; }
		}
		
		public ImportInfo (string original)
		{
			original_path = original;
		        destination_path = null;
			Photo = null;
		}
	}
	
	private void AddPath (string path)
	{
		if (FSpot.ImageFile.HasLoader (path))
			import_info.Add (new ImportInfo (path));
	}

	private void GetListing (System.IO.DirectoryInfo info)
	{
		try {
			GetListing (info, info.GetFiles (), recurse);
		} catch (System.UnauthorizedAccessException) {
			System.Console.WriteLine ("Unable to access directory {0}", info.FullName);
		} catch (System.Exception e) {
			System.Console.WriteLine ("{0}", e.ToString ());
		}
	}

	private void GetListing (System.IO.DirectoryInfo dirinfo, System.IO.FileInfo [] files, bool recurse)
	{
		Log.Debug ("Scanning {0} for new photos", dirinfo.FullName);
		List<Uri> existing_entries = new List<Uri> ();

		foreach (Photo p in store.Query (new Uri (dirinfo.FullName + "/")))
			foreach (uint id in p.VersionIds)
				existing_entries.Add (p.VersionUri (id));

		foreach (System.IO.FileInfo f in files)
			if (! existing_entries.Contains (UriUtils.PathToFileUri (f.FullName)) && !f.Name.StartsWith (".")) {
				AddPath (f.FullName);
			}

		if (recurse) {
{'fraction_non_alphanumeric': 0.10938924339106655, 'fraction_numerical': 0.0013673655423883319, 'mean_word_length': 3.9314606741573033, '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': '5491189', 'n_tokens_mistral': 1569, 'n_tokens_neox': 1410, 'n_words': 384}