diff --git a/alexandria-0.6.9-delete-broken-yaml.patch b/alexandria-0.6.9-delete-broken-yaml.patch new file mode 100644 index 0000000..8141ef6 --- /dev/null +++ b/alexandria-0.6.9-delete-broken-yaml.patch @@ -0,0 +1,87 @@ +--- alexandria-0.6.9/lib/alexandria/models/library.rb.delbroken 2012-10-25 14:39:40.029847934 +0900 ++++ alexandria-0.6.9/lib/alexandria/models/library.rb 2012-10-24 13:58:38.445172696 +0900 +@@ -98,7 +98,7 @@ + md = /([\dxX]{10,13})#{EXT[:book]}/.match(filename) + if md + file_isbn = md[1] +- ruined_books << [nil, file_isbn, library] ++ ruined_books << [nil, file_isbn, library, filename, library.path] + else + log.warn { "Filename #{filename} does not contain an ISBN"} + #TODO delete this file... +--- alexandria-0.6.9/lib/alexandria/ui/ui_manager.rb.delbroken 2012-10-25 14:39:40.026847577 +0900 ++++ alexandria-0.6.9/lib/alexandria/ui/ui_manager.rb 2012-10-24 14:03:49.811462773 +0900 +@@ -805,6 +805,73 @@ + false + end + end ++ else ## if response_type == Gtk::Dialog::RESPONSE_OK ++ handle_and_delete_ruined_books ++ end ++ end ++ end ++ ++ def handle_and_delete_ruined_books ++ title = _("Delete Book Data") ++ new_message = _("Or do you wish to delete the data files for the following books are malformed or empty?\n") ++ ++ @libraries.ruined_books.each { |bi| ++ new_message += "\n#{bi[1] or bi[1].inspect}" ++ } ++ recovery_dialog = Gtk::MessageDialog.new(@main_app, Gtk::Dialog::MODAL, ++ Gtk::MessageDialog::WARNING, ++ Gtk::MessageDialog::BUTTONS_OK_CANCEL, ++ new_message ).show ++ recovery_dialog.signal_connect('response') do |dialog, response_type| ++ recovery_dialog.destroy ++ if response_type == Gtk::Dialog::RESPONSE_OK ++ books_to_add = [] ++ ++ # progress indicator... ++ @progressbar.fraction = 0 ++ @appbar.children.first.visible = true # show the progress bar ++ ++ total_book_count = @libraries.ruined_books.size ++ fraction_per_book = 1.0 / total_book_count ++ prog_percentage = 0 ++ ++ @libraries.ruined_books.reverse! ++ Gtk.idle_add do ++ ruined_book = @libraries.ruined_books.pop ++ if ruined_book ++ book, isbn, library, filename, path = ruined_book ++ filename_path = File.join(path, filename) ++ begin ++ File.delete(filename_path) ++ set_status_label(_("The file '%s' removed") % filename) ++ log.debug {"The maybe-malformed file #{filename} removed"} ++ ++ rescue Exception => ex ++ log.error { "Could not delete #{filename_path}: #{ex}" } ++ log.error { ex.backtrace.join("\n") } ++ end ++ ++ prog_percentage += fraction_per_book ++ @progressbar.fraction = prog_percentage ++ ++ true ++ else ++ ## Totally copied and pasted from refresh_books... ++ ## call this the second strike... (CathalMagus) ++ ++ # @iconview.unfreeze ++ # @filtered_model.refilter ++ # @listview.columns_autosize ++ ++ @progressbar.fraction = 1 ++ ## Hide the progress bar. ++ @appbar.children.first.visible = false ++ ## Refresh the status bar. ++ set_status_label('') ++ # on_books_selection_changed ++ false ++ end ++ end + end + end + end diff --git a/alexandria.spec b/alexandria.spec index 68045b8..3305221 100644 --- a/alexandria.spec +++ b/alexandria.spec @@ -9,7 +9,7 @@ %undefine minorver %undefine ifpre -%define fedorarel 1 +%define fedorarel 2 %define rel %{?ifpre:0.}%{fedorarel}%{?minorver:.%minorver} @@ -77,6 +77,9 @@ Patch21: alexandria-0.6.8-iconview-multibyte.patch # user redownload it # (bug 861740) Patch22: alexandria-0.6.8-yaml-unescape.patch +# Add a feature to remove broken yaml files at startup when requested +# (bug 869556) +Patch23: alexandria-0.6.9-delete-broken-yaml.patch BuildArch: noarch BuildRequires: ruby(abi) >= %{rubyabi} @@ -149,6 +152,7 @@ Alexandria is a GNOME application to help you manage your book collection. %patch20 -p1 -b .export_csv %patch21 -p1 -b .icon_kanji %patch22 -p1 -b .broken_yaml +%patch23 -p1 -b .delete_yaml # Embed Fedora EVR %{__sed} -i.evr \ @@ -243,6 +247,10 @@ exit 0 %{_datadir}/icons/hicolor/*/apps/%{name}.* %changelog +* Sat Oct 27 2012 Mamoru Tasaka - 0.6.9-2 +- Add a feature to remove broken yaml files at startup when requested + (bug 869556) + * Sun Oct 14 2012 Mamoru Tasaka - 0.6.9-1 - 0.6.9