From 7a046e92cb8ddb0170f94a68baf3840d5b1ece60 Mon Sep 17 00:00:00 2001 From: Michael Pyne Date: Mon, 7 Mar 2011 19:23:58 -0500 Subject: [PATCH] Try to corruption-proof the module database. Following on with the last commit, if an exception is thrown while parsing XML modules, the database is re-downloaded once, which should hopefully automatically fix things if the XML gets corrupted. --- kdesrc-build | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/kdesrc-build b/kdesrc-build index b695b3d..73bea18 100755 --- a/kdesrc-build +++ b/kdesrc-build @@ -3610,9 +3610,14 @@ EOF # work. Only tries once per script run. If it does succeed, the result is saved # to $srcdir/kde_projects.xml # +# Accepts options as a set of key/value pairs (i.e. a standard Perl hash), the +# only one currently is "force", which if set to anything will unlink the xml +# file first, even in pretend mode. +# # Returns 0 if the file could not be downloaded, 1 otherwise. sub ensure_projects_xml_present { + my %opts = @_; my $srcdir = get_source_dir(); my $cached_status = get_option('global', '#cached_project_xml_check'); @@ -3629,6 +3634,8 @@ sub ensure_projects_xml_present my $path = "/kde_projects.xml"; my $redirections = { }; + unlink $file if exists $opts{force}; + my $result = 1; if (!pretending) { info " * Downloading projects.kde.org project database..."; @@ -4245,6 +4252,12 @@ sub set_option } } +sub delete_option +{ + my ($module, $option) = @_; + delete $package_opts{$module}{$option} if exists $package_opts{$module}{$option}; +} + # Sets a "persistent" option which will be read in for a module when kdesrc-build starts # up and written back out at (normal) program exit. # @@ -7880,7 +7893,15 @@ eval # be OK since there's nothing different going on from the first pass in that # event. @modules = applyModuleFilters(@modules); - @modules = expandXMLModules(@modules); + + eval { + @modules = expandXMLModules(@modules); + } or do { + warning "\n b[y[* * *] The KDE module database file appears to be corrupt, re-downloading.\n"; + delete_option('global', '#cached_project_xml_check'); + ensure_projects_xml_present(force => 1); + @modules = expandXMLModules(@modules); + }; # If modules were on the command line then they are effectively forced to # process unless overridden by command line options as well. If phases