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
eb35f892
Unverified
Commit
eb35f892
authored
Nov 15, 2018
by
Greg Spencer
Committed by
GitHub
Nov 15, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Reland: Make the 'time to update' message depend up on the channel. (#24173) (#24321)
Fixes #24158 Re-lands #24173
parent
87156df6
Changes
3
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
382 additions
and
329 deletions
+382
-329
version.dart
packages/flutter_tools/lib/src/version.dart
+29
-15
channel_test.dart
packages/flutter_tools/test/channel_test.dart
+1
-1
version_test.dart
packages/flutter_tools/test/version_test.dart
+352
-313
No files found.
packages/flutter_tools/lib/src/version.dart
View file @
eb35f892
...
...
@@ -207,20 +207,34 @@ class FlutterVersion {
/// The amount of time we wait before pinging the server to check for the
/// availability of a newer version of Flutter.
@visibleForTesting
static
const
Duration
kC
heckAgeConsideredUpToDate
=
Duration
(
days:
3
);
static
const
Duration
c
heckAgeConsideredUpToDate
=
Duration
(
days:
3
);
/// We warn the user if the age of their Flutter installation is greater than
/// this duration.
/// this duration. The durations are slightly longer than the expected release
/// cadence for each channel, to give the user a grace period before they get
/// notified.
///
/// This is set to 5 weeks because releases are currently around every 4 weeks.
/// For example, for the beta channel, this is set to five weeks because
/// beta releases happen approximately every month.
@visibleForTesting
static
const
Duration
kVersionAgeConsideredUpToDate
=
Duration
(
days:
35
);
static
Duration
versionAgeConsideredUpToDate
(
String
channel
)
{
switch
(
channel
)
{
case
'stable'
:
return
const
Duration
(
days:
365
~/
2
);
// Six months
case
'beta'
:
return
const
Duration
(
days:
7
*
8
);
// Eight weeks
case
'dev'
:
return
const
Duration
(
days:
7
*
4
);
// Four weeks
default
:
return
const
Duration
(
days:
7
*
3
);
// Three weeks
}
}
/// The amount of time we wait between issuing a warning.
///
/// This is to avoid annoying users who are unable to upgrade right away.
@visibleForTesting
static
const
Duration
kM
axTimeSinceLastWarning
=
Duration
(
days:
1
);
static
const
Duration
m
axTimeSinceLastWarning
=
Duration
(
days:
1
);
/// The amount of time we pause for to let the user read the message about
/// outdated Flutter installation.
...
...
@@ -238,7 +252,7 @@ class FlutterVersion {
static
Future
<
void
>
resetFlutterVersionFreshnessCheck
()
async
{
try
{
await
Cache
.
instance
.
getStampFileFor
(
VersionCheckStamp
.
kF
lutterVersionCheckStampFile
,
VersionCheckStamp
.
f
lutterVersionCheckStampFile
,
).
delete
();
}
on
FileSystemException
{
// Ignore, since we don't mind if the file didn't exist in the first place.
...
...
@@ -258,7 +272,7 @@ class FlutterVersion {
final
DateTime
localFrameworkCommitDate
=
DateTime
.
parse
(
frameworkCommitDate
);
final
Duration
frameworkAge
=
_clock
.
now
().
difference
(
localFrameworkCommitDate
);
final
bool
installationSeemsOutdated
=
frameworkAge
>
kVersionAgeConsideredUpToDate
;
final
bool
installationSeemsOutdated
=
frameworkAge
>
versionAgeConsideredUpToDate
(
channel
)
;
// Get whether there's a newer version on the remote. This only goes
// to the server if we haven't checked recently so won't happen on every
...
...
@@ -273,8 +287,8 @@ class FlutterVersion {
// Do not load the stamp before the above server check as it may modify the stamp file.
final
VersionCheckStamp
stamp
=
await
VersionCheckStamp
.
load
();
final
DateTime
lastTimeWarningWasPrinted
=
stamp
.
lastTimeWarningWasPrinted
??
_clock
.
ago
(
kM
axTimeSinceLastWarning
*
2
);
final
bool
beenAWhileSinceWarningWasPrinted
=
_clock
.
now
().
difference
(
lastTimeWarningWasPrinted
)
>
kM
axTimeSinceLastWarning
;
final
DateTime
lastTimeWarningWasPrinted
=
stamp
.
lastTimeWarningWasPrinted
??
_clock
.
ago
(
m
axTimeSinceLastWarning
*
2
);
final
bool
beenAWhileSinceWarningWasPrinted
=
_clock
.
now
().
difference
(
lastTimeWarningWasPrinted
)
>
m
axTimeSinceLastWarning
;
// We show a warning if either we know there is a new remote version, or we couldn't tell but the local
// version is outdated.
...
...
@@ -327,7 +341,7 @@ class FlutterVersion {
/// Gets the release date of the latest available Flutter version.
///
/// This method sends a server request if it's been more than
/// [
kC
heckAgeConsideredUpToDate] since the last version check.
/// [
c
heckAgeConsideredUpToDate] since the last version check.
///
/// Returns null if the cached version is out-of-date or missing, and we are
/// unable to reach the server to get the latest version.
...
...
@@ -339,7 +353,7 @@ class FlutterVersion {
final
Duration
timeSinceLastCheck
=
_clock
.
now
().
difference
(
versionCheckStamp
.
lastTimeVersionWasChecked
);
// Don't ping the server too often. Return cached value if it's fresh.
if
(
timeSinceLastCheck
<
kC
heckAgeConsideredUpToDate
)
if
(
timeSinceLastCheck
<
c
heckAgeConsideredUpToDate
)
return
versionCheckStamp
.
lastKnownRemoteVersion
;
}
...
...
@@ -381,10 +395,10 @@ class VersionCheckStamp {
/// The prefix of the stamp file where we cache Flutter version check data.
@visibleForTesting
static
const
String
kF
lutterVersionCheckStampFile
=
'flutter_version_check'
;
static
const
String
f
lutterVersionCheckStampFile
=
'flutter_version_check'
;
static
Future
<
VersionCheckStamp
>
load
()
async
{
final
String
versionCheckStamp
=
Cache
.
instance
.
getStampFor
(
kF
lutterVersionCheckStampFile
);
final
String
versionCheckStamp
=
Cache
.
instance
.
getStampFor
(
f
lutterVersionCheckStampFile
);
if
(
versionCheckStamp
!=
null
)
{
// Attempt to parse stamp JSON.
...
...
@@ -435,8 +449,8 @@ class VersionCheckStamp {
if
(
newTimeWarningWasPrinted
!=
null
)
jsonData
[
'lastTimeWarningWasPrinted'
]
=
'
$newTimeWarningWasPrinted
'
;
const
JsonEncoder
kP
rettyJsonEncoder
=
JsonEncoder
.
withIndent
(
' '
);
Cache
.
instance
.
setStampFor
(
kFlutterVersionCheckStampFile
,
kP
rettyJsonEncoder
.
convert
(
jsonData
));
const
JsonEncoder
p
rettyJsonEncoder
=
JsonEncoder
.
withIndent
(
' '
);
Cache
.
instance
.
setStampFor
(
flutterVersionCheckStampFile
,
p
rettyJsonEncoder
.
convert
(
jsonData
));
}
Map
<
String
,
String
>
toJson
({
...
...
packages/flutter_tools/test/channel_test.dart
View file @
eb35f892
...
...
@@ -188,7 +188,7 @@ void main() {
)).
thenAnswer
((
_
)
=>
Future
<
Process
>.
value
(
createMockProcess
()));
final
File
versionCheckFile
=
Cache
.
instance
.
getStampFileFor
(
VersionCheckStamp
.
kF
lutterVersionCheckStampFile
,
VersionCheckStamp
.
f
lutterVersionCheckStampFile
,
);
/// Create a bogus "leftover" version check file to make sure it gets
...
...
packages/flutter_tools/test/version_test.dart
View file @
eb35f892
This diff is collapsed.
Click to expand it.
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