Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
bdc06194
Unverified
Commit
bdc06194
authored
Apr 07, 2018
by
xster
Committed by
GitHub
Apr 07, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Prompt a solution message when flutter tools network fail in China (#16244)
parent
d6d87447
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
56 additions
and
4 deletions
+56
-4
update_dart_sdk.sh
bin/internal/update_dart_sdk.sh
+9
-1
cache.dart
packages/flutter_tools/lib/src/cache.dart
+20
-3
cache_test.dart
packages/flutter_tools/test/cache_test.dart
+27
-0
No files found.
bin/internal/update_dart_sdk.sh
View file @
bdc06194
...
...
@@ -51,7 +51,15 @@ if [ ! -f "$ENGINE_STAMP" ] || [ "$ENGINE_VERSION" != `cat "$ENGINE_STAMP"` ]; t
mkdir
-p
--
"
$DART_SDK_PATH
"
DART_SDK_ZIP
=
"
$FLUTTER_ROOT
/bin/cache/
$DART_ZIP_NAME
"
curl
--continue-at
-
--location
--output
"
$DART_SDK_ZIP
"
"
$DART_SDK_URL
"
2>&1
curl
--continue-at
-
--location
--output
"
$DART_SDK_ZIP
"
"
$DART_SDK_URL
"
2>&1
||
{
echo
echo
"Failed to retrieve the Dart SDK at
$DART_SDK_URL
"
echo
"If you're located in China, please follow"
echo
"https://github.com/flutter/flutter/wiki/Using-Flutter-in-China"
echo
rm
-f
--
"
$DART_SDK_ZIP
"
exit
1
}
unzip
-o
-q
"
$DART_SDK_ZIP
"
-d
"
$FLUTTER_ROOT
/bin/cache"
||
{
echo
echo
"It appears that the downloaded file is corrupt; please try the operation again later."
...
...
packages/flutter_tools/lib/src/cache.dart
View file @
bdc06194
...
...
@@ -8,6 +8,7 @@ import 'package:meta/meta.dart';
import
'base/context.dart'
;
import
'base/file_system.dart'
;
import
'base/io.dart'
show
SocketException
;
import
'base/logger.dart'
;
import
'base/net.dart'
;
import
'base/os.dart'
;
...
...
@@ -28,6 +29,10 @@ class Cache {
}
}
static
const
List
<
String
>
_hostsBlockedInChina
=
const
<
String
>
[
'storage.googleapis.com'
,
];
final
Directory
_rootOverride
;
final
List
<
CachedArtifact
>
_artifacts
=
<
CachedArtifact
>[];
...
...
@@ -190,9 +195,21 @@ class Cache {
Future
<
Null
>
updateAll
()
async
{
if
(!
_lockEnabled
)
return
null
;
for
(
CachedArtifact
artifact
in
_artifacts
)
{
if
(!
artifact
.
isUpToDate
())
await
artifact
.
update
();
try
{
for
(
CachedArtifact
artifact
in
_artifacts
)
{
if
(!
artifact
.
isUpToDate
())
await
artifact
.
update
();
}
}
on
SocketException
catch
(
e
)
{
if
(
_hostsBlockedInChina
.
contains
(
e
.
address
?.
host
))
{
printError
(
'Failed to retrieve Flutter tool depedencies:
${e.message}
.
\n
'
"If you're in China, please follow "
'https://github.com/flutter/flutter/wiki/Using-Flutter-in-China'
,
emphasis:
true
,
);
}
rethrow
;
}
}
}
...
...
packages/flutter_tools/test/cache_test.dart
View file @
bdc06194
...
...
@@ -11,6 +11,7 @@ import 'package:test/test.dart';
import
'package:platform/platform.dart'
;
import
'package:flutter_tools/src/cache.dart'
;
import
'package:flutter_tools/src/base/io.dart'
show
InternetAddress
,
SocketException
;
import
'src/context.dart'
;
...
...
@@ -76,6 +77,31 @@ void main() {
verifyNever
(
artifact1
.
update
());
verify
(
artifact2
.
update
());
});
testUsingContext
(
'failed storage.googleapis.com download shows China warning'
,
()
async
{
final
CachedArtifact
artifact1
=
new
MockCachedArtifact
();
final
CachedArtifact
artifact2
=
new
MockCachedArtifact
();
when
(
artifact1
.
isUpToDate
()).
thenReturn
(
false
);
when
(
artifact2
.
isUpToDate
()).
thenReturn
(
false
);
final
MockInternetAddress
address
=
new
MockInternetAddress
();
when
(
address
.
host
).
thenReturn
(
'storage.googleapis.com'
);
when
(
artifact1
.
update
()).
thenThrow
(
new
SocketException
(
'Connection reset by peer'
,
address:
address
,
));
final
Cache
cache
=
new
Cache
(
artifacts:
<
CachedArtifact
>[
artifact1
,
artifact2
]);
try
{
await
cache
.
updateAll
();
fail
(
'Mock thrown exception expected'
);
}
catch
(
e
)
{
verify
(
artifact1
.
update
());
// Don't continue when retrieval fails.
verifyNever
(
artifact2
.
update
());
expect
(
testLogger
.
errorText
,
contains
(
'https://github.com/flutter/flutter/wiki/Using-Flutter-in-China'
),
);
}
});
});
testUsingContext
(
'flattenNameSubdirs'
,
()
{
...
...
@@ -103,3 +129,4 @@ class MockFile extends Mock implements File {
class
MockRandomAccessFile
extends
Mock
implements
RandomAccessFile
{}
class
MockCachedArtifact
extends
Mock
implements
CachedArtifact
{}
class
MockInternetAddress
extends
Mock
implements
InternetAddress
{}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment