void Cleanup() { if (imported_photos != null && imported_photos.Count == 0) { rolls.Remove(CreatedRoll); } imported_photos = null; created_directories = null; Photo.ResetMD5Cache(); DeactivateSource(ActiveSource); GC.Collect(); App.Instance.Database.Sync = true; }
public override void Cancel() { if (import_info == null) { throw new ImportException("Not doing anything"); } foreach (ImportInfo info in import_info) { if (info.OriginalPath != info.DestinationPath) { try { System.IO.File.Delete(info.DestinationPath); } catch (System.ArgumentNullException) { // Do nothing, since if DestinationPath == null, we do not have to remove it } catch (System.Exception e) { System.Console.WriteLine(e); } } if (info.Photo != null) { store.Remove(info.Photo); } } // clean up all the directories we created. if (copy) { string path; System.IO.DirectoryInfo info; while (directories.Count > 0) { path = directories.Pop() as string; info = new System.IO.DirectoryInfo(path); // double check we aren't trying to delete a directory that still contains something! if (info.Exists && info.GetFiles().Length == 0 && info.GetDirectories().Length == 0) { info.Delete(); } } } // Clean up just created tags xmptags.Cancel(); rolls.Remove(roll); }