diff --git a/src/pakfire/lib/functions.pl b/src/pakfire/lib/functions.pl
index 12a405bd7..bbc580ad2 100644
--- a/src/pakfire/lib/functions.pl
+++ b/src/pakfire/lib/functions.pl
@@ -180,7 +180,14 @@ sub fetchfile {
 		my $result = $ua->head($url);
 		my $remote_headers = $result->headers;
 		$total_size = $remote_headers->content_length;
-		logger("DOWNLOAD INFO: $file has size of $total_size bytes");
+
+		# validate if file download was successful (size <= 0)
+		if ( $total_size eq "0" || not $total_size ) {
+			logger("DOWNLOAD ERROR: download of $file failed with size '$total_size' bytes");
+			return 1;
+		} else {
+			logger("DOWNLOAD INFO: $file has size of $total_size bytes");
+		}
 		
 		my $response = $ua->get($url, ':content_cb' => \&callback );
 		message("");
