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
77e15103
Unverified
Commit
77e15103
authored
Aug 09, 2019
by
Jonah Williams
Committed by
GitHub
Aug 09, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Catch failure to create directory in cache (#37871)
parent
361730ed
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
1 deletion
+31
-1
cache.dart
packages/flutter_tools/lib/src/cache.dart
+9
-1
cache_test.dart
packages/flutter_tools/test/general.shard/cache_test.dart
+22
-0
No files found.
packages/flutter_tools/lib/src/cache.dart
View file @
77e15103
...
...
@@ -398,7 +398,15 @@ abstract class CachedArtifact {
return
;
}
if
(!
location
.
existsSync
())
{
location
.
createSync
(
recursive:
true
);
try
{
location
.
createSync
(
recursive:
true
);
}
on
FileSystemException
catch
(
err
)
{
printError
(
err
.
toString
());
throwToolExit
(
'Failed to create directory for flutter cache at
${location.path}
. '
'Flutter may be missing permissions in its cache directory.'
);
}
}
await
updateInner
();
cache
.
setStampFor
(
stampName
,
version
);
...
...
packages/flutter_tools/test/general.shard/cache_test.dart
View file @
77e15103
...
...
@@ -243,6 +243,27 @@ void main() {
Platform:
()
=>
fakePlatform
,
});
});
testUsingContext
(
'throws tool exit on fs exception'
,
()
async
{
final
FakeCachedArtifact
fakeCachedArtifact
=
FakeCachedArtifact
(
cache:
MockCache
(),
requiredArtifacts:
<
DevelopmentArtifact
>{
DevelopmentArtifact
.
android
,
}
);
final
Directory
mockDirectory
=
MockDirectory
();
when
(
fakeCachedArtifact
.
cache
.
getArtifactDirectory
(
any
))
.
thenReturn
(
mockDirectory
);
when
(
mockDirectory
.
existsSync
()).
thenReturn
(
false
);
when
(
mockDirectory
.
createSync
(
recursive:
true
))
.
thenThrow
(
const
FileSystemException
());
expect
(()
=>
fakeCachedArtifact
.
update
(<
DevelopmentArtifact
>{
DevelopmentArtifact
.
android
,
}),
throwsA
(
isInstanceOf
<
ToolExit
>()));
},
overrides:
<
Type
,
Generator
>{
FileSystem:
()
=>
MemoryFileSystem
(),
});
}
class
FakeCachedArtifact
extends
EngineCachedArtifact
{
...
...
@@ -271,6 +292,7 @@ class FakeCachedArtifact extends EngineCachedArtifact {
class
MockFileSystem
extends
Mock
implements
FileSystem
{}
class
MockFile
extends
Mock
implements
File
{}
class
MockDirectory
extends
Mock
implements
Directory
{}
class
MockRandomAccessFile
extends
Mock
implements
RandomAccessFile
{}
class
MockCachedArtifact
extends
Mock
implements
CachedArtifact
{}
...
...
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