void RollbackImport() { // Remove photos foreach (var id in imported_photos) { store.Remove(store.Get(id)); } foreach (var uri in photo_file_tracker.CopiedFiles) { var file = GLib.FileFactory.NewForUri(uri); file.Delete(null); } // Clean up directories while (created_directories.Count > 0) { var uri = created_directories.Pop(); var dir = GLib.FileFactory.NewForUri(uri); var enumerator = dir.EnumerateChildren("standard::name", GLib.FileQueryInfoFlags.None, null); if (!enumerator.HasPending) { dir.Delete(null); } } // Clean created tags metadata_importer.Cancel(); // Remove created roll rolls.Remove(CreatedRoll); }
void RollbackImport(IDb db) { // Remove photos foreach (var id in imported_photos) { db.Photos.Remove(db.Photos.Get(id)); } foreach (var uri in photo_file_tracker.CopiedFiles) { fileSystem.File.Delete(uri); } // Clean up directories while (created_directories.Count > 0) { var uri = created_directories.Pop(); try { fileSystem.Directory.Delete(uri); } catch (Exception e) { Log.WarningFormat("Failed to clean up directory '{0}': {1}", uri, e.Message); } } // Clean created tags metadata_importer.Cancel(); // Remove created roll db.Rolls.Remove(createdRoll); }