75
77
private void GetListing (System.IO.DirectoryInfo dirinfo, System.IO.FileInfo [] files, bool recurse)
77
System.Console.WriteLine ("Scanning {0}", dirinfo.FullName);
79
Log.DebugFormat ("Scanning {0} for new photos", dirinfo.FullName);
78
80
List<Uri> existing_entries = new List<Uri> ();
80
foreach (Photo p in store.Query (dirinfo)) {
81
foreach (uint id in p.VersionIds) {
82
foreach (Photo p in store.Query (new Uri (dirinfo.FullName)))
83
foreach (uint id in p.VersionIds)
82
84
existing_entries.Add (p.VersionUri (id));
86
foreach (System.IO.FileInfo f in files) {
86
foreach (System.IO.FileInfo f in files)
87
87
if (! existing_entries.Contains (UriUtils.PathToFileUri (f.FullName)) && !f.Name.StartsWith (".")) {
88
88
AddPath (f.FullName);
93
92
foreach (System.IO.DirectoryInfo d in dirinfo.GetDirectories ()){
212
214
string destination = info.OriginalPath;
214
216
destination = ChooseLocation (info.OriginalPath, directories);
216
218
// Don't copy if we are already home
217
219
if (info.OriginalPath == destination) {
218
220
info.DestinationPath = destination;
219
photo = store.Create (info.DestinationPath, roll.Id, out thumbnail);
222
if (detect_duplicates)
223
photo = store.CheckForDuplicate (UriUtils.PathToFileUri (destination));
226
photo = store.Create (info.DestinationPath, roll.Id, out thumbnail);
221
230
System.IO.File.Copy (info.OriginalPath, destination);
222
231
info.DestinationPath = destination;
224
photo = store.Create (info.DestinationPath, info.OriginalPath, roll.Id, out thumbnail);
227
File.SetAttributes (destination, File.GetAttributes (info.DestinationPath) & ~FileAttributes.ReadOnly);
228
DateTime create = File.GetCreationTime (info.OriginalPath);
229
File.SetCreationTime (info.DestinationPath, create);
230
DateTime mod = File.GetLastWriteTime (info.OriginalPath);
231
File.SetLastWriteTime (info.DestinationPath, mod);
232
} catch (IOException) {
233
// we don't want an exception here to be fatal.
233
if (detect_duplicates)
234
photo = store.CheckForDuplicate (UriUtils.PathToFileUri (destination));
238
photo = store.Create (info.DestinationPath, info.OriginalPath, roll.Id, out thumbnail);
242
File.SetAttributes (destination, File.GetAttributes (info.DestinationPath) & ~FileAttributes.ReadOnly);
243
DateTime create = File.GetCreationTime (info.OriginalPath);
244
File.SetCreationTime (info.DestinationPath, create);
245
DateTime mod = File.GetLastWriteTime (info.OriginalPath);
246
File.SetLastWriteTime (info.DestinationPath, mod);
247
} catch (IOException) {
248
// we don't want an exception here to be fatal.
254
System.IO.File.Delete (destination);
238
foreach (Tag t in tags) {
261
foreach (Tag t in tags) {
267
needs_commit |= xmptags.Import (photo, info.DestinationPath, info.OriginalPath);
244
needs_commit |= xmptags.Import (photo, info.DestinationPath, info.OriginalPath);
250
274
} catch (System.Exception e) {
251
275
System.Console.WriteLine ("Error importing {0}{2}{1}", info.OriginalPath, e.ToString (), Environment.NewLine);
252
276
if (thumbnail != null)
326
354
import_info = null;
327
355
xmptags.Finish();
329
//rolls.EndImport(); // Clean up the imported session.
356
Photo.ResetMD5Cache ();
358
if (count == duplicate_count)
361
count = duplicate_count = 0;
362
//rolls.EndImport(); // Clean up the imported session.
332
public FileImportBackend (PhotoStore store, string [] base_paths, bool recurse, Gtk.Window parent) : this (store, base_paths, false, recurse, null, parent) {}
334
public FileImportBackend (PhotoStore store, string [] base_paths, bool copy, bool recurse, Tag [] tags, Gtk.Window parent)
365
public FileImportBackend (PhotoStore store, string [] base_paths, bool recurse, Gtk.Window parent) : this (store, base_paths, false, recurse, false, null, parent) {}
367
public FileImportBackend (PhotoStore store, string [] base_paths, bool copy, bool recurse, Tag [] tags, Gtk.Window parent) : this (store, base_paths, copy, recurse, false, null, parent) {}
369
public FileImportBackend (PhotoStore store, string [] base_paths, bool copy, bool recurse, bool detect_duplicates, Tag [] tags, Gtk.Window parent)
336
371
this.store = store;
337
372
this.copy = copy;
338
373
this.base_paths = base_paths;
339
374
this.recurse = recurse;
375
this.detect_duplicates = detect_duplicates;
340
376
this.tags = tags;
341
377
this.parent = parent;