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
b142c9bb
Unverified
Commit
b142c9bb
authored
Oct 28, 2019
by
Jonah Williams
Committed by
GitHub
Oct 28, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
catch failure to parse FLUTTER_STORAGE_BASE_URL (#43599)
parent
450a7248
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
6 deletions
+27
-6
cache.dart
packages/flutter_tools/lib/src/cache.dart
+13
-6
cache_test.dart
packages/flutter_tools/test/general.shard/cache_test.dart
+14
-0
No files found.
packages/flutter_tools/lib/src/cache.dart
View file @
b142c9bb
...
...
@@ -482,16 +482,23 @@ abstract class CachedArtifact extends ArtifactSet {
/// Template method to perform artifact update.
Future
<
void
>
updateInner
();
String
get
_storageBaseUrl
{
@visibleForTesting
String
get
storageBaseUrl
{
final
String
overrideUrl
=
platform
.
environment
[
'FLUTTER_STORAGE_BASE_URL'
];
if
(
overrideUrl
==
null
)
{
return
'https://storage.googleapis.com'
;
}
// verify that this is a valid URI.
try
{
Uri
.
parse
(
overrideUrl
);
}
on
FormatException
catch
(
err
)
{
throwToolExit
(
'"FLUTTER_STORAGE_BASE_URL" contains an invalid URI:
\n
$err
'
);
}
_maybeWarnAboutStorageOverride
(
overrideUrl
);
return
overrideUrl
;
}
Uri
_toStorageUri
(
String
path
)
=>
Uri
.
parse
(
'
$
_
storageBaseUrl
/
$path
'
);
Uri
_toStorageUri
(
String
path
)
=>
Uri
.
parse
(
'
$storageBaseUrl
/
$path
'
);
/// Download an archive from the given [url] and unzip it to [location].
Future
<
void
>
_downloadArchive
(
String
message
,
Uri
url
,
Directory
location
,
bool
verifier
(
File
f
),
void
extractor
(
File
f
,
Directory
d
))
{
...
...
@@ -587,7 +594,7 @@ class FlutterWebSdk extends CachedArtifact {
}
else
if
(
platform
.
isWindows
)
{
platformName
+=
'windows-x64'
;
}
final
Uri
url
=
Uri
.
parse
(
'
$
_
storageBaseUrl
/flutter_infra/flutter/
$version
/
$platformName
.zip'
);
final
Uri
url
=
Uri
.
parse
(
'
$storageBaseUrl
/flutter_infra/flutter/
$version
/
$platformName
.zip'
);
await
_downloadZipArchive
(
'Downloading Web SDK...'
,
url
,
location
);
// This is a temporary work-around for not being able to safely download into a shared directory.
for
(
FileSystemEntity
entity
in
location
.
listSync
(
recursive:
true
))
{
...
...
@@ -652,7 +659,7 @@ abstract class EngineCachedArtifact extends CachedArtifact {
@override
Future
<
void
>
updateInner
()
async
{
final
String
url
=
'
$
_
storageBaseUrl
/flutter_infra/flutter/
$version
/'
;
final
String
url
=
'
$storageBaseUrl
/flutter_infra/flutter/
$version
/'
;
final
Directory
pkgDir
=
cache
.
getCacheDir
(
'pkg'
);
for
(
String
pkgName
in
getPackageDirs
())
{
...
...
@@ -687,7 +694,7 @@ abstract class EngineCachedArtifact extends CachedArtifact {
Future
<
bool
>
checkForArtifacts
(
String
engineVersion
)
async
{
engineVersion
??=
version
;
final
String
url
=
'
$
_
storageBaseUrl
/flutter_infra/flutter/
$engineVersion
/'
;
final
String
url
=
'
$storageBaseUrl
/flutter_infra/flutter/
$engineVersion
/'
;
bool
exists
=
false
;
for
(
String
pkgName
in
getPackageDirs
())
{
...
...
@@ -1111,7 +1118,7 @@ class IosUsbArtifacts extends CachedArtifact {
}
@visibleForTesting
Uri
get
archiveUri
=>
Uri
.
parse
(
'
$
_
storageBaseUrl
/flutter_infra/ios-usb-dependencies
${cache.useUnsignedMacBinaries ? '/unsigned' : ''}
/
$name
/
$version
/
$name
.zip'
);
Uri
get
archiveUri
=>
Uri
.
parse
(
'
$storageBaseUrl
/flutter_infra/ios-usb-dependencies
${cache.useUnsignedMacBinaries ? '/unsigned' : ''}
/
$name
/
$version
/
$name
.zip'
);
}
// Many characters are problematic in filenames, especially on Windows.
...
...
packages/flutter_tools/test/general.shard/cache_test.dart
View file @
b142c9bb
...
...
@@ -5,6 +5,7 @@
import
'package:file/file.dart'
;
import
'package:file/memory.dart'
;
import
'package:file_testing/file_testing.dart'
;
import
'package:flutter_tools/src/base/platform.dart'
;
import
'package:meta/meta.dart'
;
import
'package:mockito/mockito.dart'
;
import
'package:platform/platform.dart'
;
...
...
@@ -202,6 +203,18 @@ void main() {
);
}
});
testUsingContext
(
'Invalid URI for FLUTTER_STORAGE_BASE_URL throws ToolExit'
,
()
async
{
when
(
platform
.
environment
).
thenReturn
(
const
<
String
,
String
>{
'FLUTTER_STORAGE_BASE_URL'
:
' http://foo'
,
});
final
Cache
cache
=
Cache
();
final
CachedArtifact
artifact
=
MaterialFonts
(
cache
);
expect
(()
=>
artifact
.
storageBaseUrl
,
throwsA
(
isInstanceOf
<
ToolExit
>()));
},
overrides:
<
Type
,
Generator
>{
Platform:
()
=>
MockPlatform
(),
});
});
testUsingContext
(
'flattenNameSubdirs'
,
()
{
...
...
@@ -379,3 +392,4 @@ class MockIosUsbArtifacts extends Mock implements IosUsbArtifacts {}
class
MockInternetAddress
extends
Mock
implements
InternetAddress
{}
class
MockCache
extends
Mock
implements
Cache
{}
class
MockOperatingSystemUtils
extends
Mock
implements
OperatingSystemUtils
{}
class
MockPlatform
extends
Mock
implements
Platform
{}
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