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
485ed2f6
Unverified
Commit
485ed2f6
authored
Oct 09, 2018
by
Greg Spencer
Committed by
GitHub
Oct 09, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix DevFS to understand missing files in _stat() (#22844)
Fixes #22451
parent
fb7a5937
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
59 additions
and
9 deletions
+59
-9
devfs.dart
packages/flutter_tools/lib/src/devfs.dart
+29
-9
devfs_test.dart
packages/flutter_tools/test/devfs_test.dart
+30
-0
No files found.
packages/flutter_tools/lib/src/devfs.dart
View file @
485ed2f6
...
...
@@ -83,20 +83,32 @@ class DevFSFileContent extends DevFSContent {
void
_stat
()
{
if
(
_linkTarget
!=
null
)
{
// Stat the cached symlink target.
_fileStat
=
_linkTarget
.
statSync
();
return
;
final
FileStat
fileStat
=
_linkTarget
.
statSync
();
if
(
fileStat
.
type
==
FileSystemEntityType
.
notFound
)
{
_linkTarget
=
null
;
}
else
{
_fileStat
=
fileStat
;
return
;
}
}
_fileStat
=
file
.
statSync
();
if
(
_fileStat
.
type
==
FileSystemEntityType
.
link
)
{
final
FileStat
fileStat
=
file
.
statSync
();
_fileStat
=
fileStat
.
type
==
FileSystemEntityType
.
notFound
?
null
:
fileStat
;
if
(
_fileStat
!=
null
&&
_fileStat
.
type
==
FileSystemEntityType
.
link
)
{
// Resolve, stat, and maybe cache the symlink target.
final
String
resolved
=
file
.
resolveSymbolicLinksSync
();
final
FileSystemEntity
linkTarget
=
fs
.
file
(
resolved
);
// Stat the link target.
_fileStat
=
linkTarget
.
statSync
();
if
(
devFSConfig
.
cacheSymlinks
)
{
final
FileStat
fileStat
=
linkTarget
.
statSync
();
if
(
fileStat
.
type
==
FileSystemEntityType
.
notFound
)
{
_fileStat
=
null
;
_linkTarget
=
null
;
}
else
if
(
devFSConfig
.
cacheSymlinks
)
{
_linkTarget
=
linkTarget
;
}
}
if
(
_fileStat
==
null
)
{
printError
(
'Unable to get status of file "
${file.path}
": file not found.'
);
}
}
@override
...
...
@@ -106,21 +118,29 @@ class DevFSFileContent extends DevFSContent {
bool
get
isModified
{
final
FileStat
_oldFileStat
=
_fileStat
;
_stat
();
return
_oldFileStat
==
null
||
_fileStat
.
modified
.
isAfter
(
_oldFileStat
.
modified
);
if
(
_oldFileStat
==
null
&&
_fileStat
==
null
)
return
false
;
return
_oldFileStat
==
null
||
_fileStat
==
null
||
_fileStat
.
modified
.
isAfter
(
_oldFileStat
.
modified
);
}
@override
bool
isModifiedAfter
(
DateTime
time
)
{
final
FileStat
_oldFileStat
=
_fileStat
;
_stat
();
return
_oldFileStat
==
null
||
time
==
null
||
_fileStat
.
modified
.
isAfter
(
time
);
if
(
_oldFileStat
==
null
&&
_fileStat
==
null
)
return
false
;
return
time
==
null
||
_oldFileStat
==
null
||
_fileStat
==
null
||
_fileStat
.
modified
.
isAfter
(
time
);
}
@override
int
get
size
{
if
(
_fileStat
==
null
)
_stat
();
return
_fileStat
.
size
;
// Can still be null if the file wasn't found.
return
_fileStat
?.
size
??
0
;
}
@override
...
...
packages/flutter_tools/test/devfs_test.dart
View file @
485ed2f6
...
...
@@ -62,6 +62,36 @@ void main() {
expect
(
content
.
isModified
,
isTrue
);
expect
(
content
.
isModified
,
isFalse
);
});
testUsingContext
(
'file'
,
()
async
{
final
File
file
=
fs
.
file
(
filePath
);
final
DevFSFileContent
content
=
DevFSFileContent
(
file
);
expect
(
content
.
isModified
,
isFalse
);
expect
(
content
.
isModified
,
isFalse
);
file
.
parent
.
createSync
(
recursive:
true
);
file
.
writeAsBytesSync
(<
int
>[
1
,
2
,
3
]);
final
DateTime
fiveSecondsAgo
=
DateTime
.
now
().
subtract
(
Duration
(
seconds:
5
));
expect
(
content
.
isModifiedAfter
(
fiveSecondsAgo
),
isTrue
);
expect
(
content
.
isModifiedAfter
(
fiveSecondsAgo
),
isTrue
);
expect
(
content
.
isModifiedAfter
(
null
),
isTrue
);
file
.
writeAsBytesSync
(<
int
>[
2
,
3
,
4
]);
expect
(
content
.
fileDependencies
,
<
String
>[
filePath
]);
expect
(
content
.
isModified
,
isTrue
);
expect
(
content
.
isModified
,
isFalse
);
expect
(
await
content
.
contentsAsBytes
(),
<
int
>[
2
,
3
,
4
]);
updateFileModificationTime
(
file
.
path
,
fiveSecondsAgo
,
0
);
expect
(
content
.
isModified
,
isFalse
);
expect
(
content
.
isModified
,
isFalse
);
file
.
deleteSync
();
expect
(
content
.
isModified
,
isTrue
);
expect
(
content
.
isModified
,
isFalse
);
expect
(
content
.
isModified
,
isFalse
);
},
overrides:
<
Type
,
Generator
>{
FileSystem:
()
=>
fs
,
});
});
group
(
'devfs local'
,
()
{
...
...
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