You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Instead of attempting automatic retry, delete corrupted file and ask user to retry.
This is simpler and more reliable since WP-CLI cache manager handles re-downloads.
Co-authored-by: swissspidy <[email protected]>
WP_CLI::debug( 'Retry download also failed validation.', 'extension-command' );
53
+
// Delete the corrupted file to prevent it from being reused.
54
+
if ( PackageValidator::delete_corrupted_file( $download ) ) {
55
+
WP_CLI::debug(
56
+
'Deleted corrupted package file from cache.',
57
+
'extension-command'
58
+
);
78
59
}
79
60
80
-
// Both attempts failed - return an error.
61
+
// Return a detailed error message.
81
62
returnnew \WP_Error(
82
63
'package_validation_failed',
83
-
'Downloaded package failed validation. The file may be corrupted or the download URL may be returning an error instead of a valid zip file. Please check your network connection and try again.'
64
+
sprintf(
65
+
'Downloaded package failed validation (%s). The corrupted file has been removed from cache. Please try the command again.',
66
+
$validation->get_error_message()
67
+
)
84
68
);
85
69
}
86
-
87
-
/**
88
-
* Retries downloading a package, bypassing cache.
89
-
*
90
-
* This is called when the initial download (which may have come from cache)
91
-
* failed validation.
92
-
*
93
-
* @param string $package The URI of the package.
94
-
* @param bool $check_signatures Whether to validate file signatures.
95
-
* @param array $hook_extra Extra arguments to pass to hooked filters.
96
-
* @return string|\WP_Error The full path to the downloaded package file, or a WP_Error object.
0 commit comments