Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
automatic_updates-3406812
Manage
Activity
Members
Labels
Plan
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Issue forks
automatic_updates-3406812
Commits
7df0066d
Commit
7df0066d
authored
5 years ago
by
Lucas Hedding
Committed by
Lucas Hedding
5 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Issue
#3087196
by heddn: Handle HTTP Status 429 from quasi patch files
parent
4015b845
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/Services/InPlaceUpdate.php
+29
-9
29 additions, 9 deletions
src/Services/InPlaceUpdate.php
with
29 additions
and
9 deletions
src/Services/InPlaceUpdate.php
+
29
−
9
View file @
7df0066d
...
...
@@ -161,18 +161,38 @@ class InPlaceUpdate implements UpdateInterface {
protected
function
getArchive
(
$project_name
,
$from_version
,
$to_version
)
{
$url
=
$this
->
buildUrl
(
$project_name
,
$this
->
getQuasiPatchFileName
(
$project_name
,
$from_version
,
$to_version
));
$destination
=
$this
->
fileSystem
->
realpath
(
$this
->
fileSystem
->
getDestinationFilename
(
"temporary://
$project_name
.zip"
,
FileSystemInterface
::
EXISTS_RENAME
));
try
{
$this
->
httpClient
->
get
(
$url
,
[
'sink'
=>
$destination
]);
/** @var \Drupal\Core\Archiver\ArchiverInterface $archive */
return
$this
->
archiveManager
->
getInstance
([
'filepath'
=>
$destination
]);
$this
->
doGetArchive
(
$url
,
$destination
);
/** @var \Drupal\Core\Archiver\ArchiverInterface $archive */
return
$this
->
archiveManager
->
getInstance
([
'filepath'
=>
$destination
]);
}
/**
* Perform retrieval of archive, with delay if archive is still being created.
*
* @param string $url
* The URL to retrieve.
* @param string $destination
* The destination to download the archive.
* @param null|int $delay
* The delay, defaults to NULL.
*/
protected
function
doGetArchive
(
$url
,
$destination
,
$delay
=
NULL
)
{
try
{
$this
->
httpClient
->
get
(
$url
,
[
'sink'
=>
$destination
,
'delay'
=>
$delay
,
]);
}
catch
(
RequestException
$exception
)
{
$this
->
logger
->
error
(
'Update for "@project" to version "@version" failed for reason: @message'
,
[
'@project'
=>
$project_name
,
'@version'
=>
$to_version
,
'@message'
=>
$exception
->
getMessage
(),
]);
if
(
$exception
->
getResponse
()
->
getStatusCode
()
===
429
&&
(
$retry
=
$exception
->
getResponse
()
->
getHeader
(
'Retry-After'
)))
{
$this
->
doGetArchive
(
$url
,
$destination
,
$retry
[
0
]
*
1000
);
}
else
{
$this
->
logger
->
error
(
'Retrieval of "@url" failed with: @message'
,
[
'@url'
=>
$url
,
'@message'
=>
$exception
->
getMessage
(),
]);
}
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment