diff --git a/modules/ksb/Updater/KDEProjectMetadata.pm b/modules/ksb/Updater/KDEProjectMetadata.pm index c0489fc..ddeb9ad 100644 --- a/modules/ksb/Updater/KDEProjectMetadata.pm +++ b/modules/ksb/Updater/KDEProjectMetadata.pm @@ -49,7 +49,8 @@ sub logicalModuleGroups my $self = shift; my $path = $self->module()->fullpath('source') . "/logical-module-structure"; - my $fh = pretend_open($path) or + # The {} is an empty JSON obj to support pretend mode + my $fh = pretend_open($path, '{}') or croak_internal("Unable to read logical module structure: $!"); my ($json_hashref, $e) = do { @@ -61,7 +62,7 @@ sub logicalModuleGroups ($json, $@); # Implicit return }; - croak_runtime ("Unable to load module group data! :(\n\t$e") if $e; + croak_runtime ("Unable to load module group data from $path! :(\n\t$e") if $e; return $json_hashref; } diff --git a/modules/ksb/Util.pm b/modules/ksb/Util.pm index 48d84ce..5331fdd 100644 --- a/modules/ksb/Util.pm +++ b/modules/ksb/Util.pm @@ -628,6 +628,7 @@ sub download_file # # Parameters: # filename - Path to the file to open. +# default - String to use if the file doesn't exist in pretend mode # # Returns: # filehandle on success (supports readline() and eof()), can return boolean @@ -636,11 +637,11 @@ sub download_file sub pretend_open { my $path = shift; + my $defaultText = shift // ''; my $fh; if (pretending() && ! -e $path) { - my $simulatedFile = ''; - open $fh, '<', \$simulatedFile or return; + open $fh, '<', \$defaultText or return; } else { open $fh, '<', $path or return;