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
2c6f862b
Unverified
Commit
2c6f862b
authored
Sep 21, 2020
by
Jonah Williams
Committed by
GitHub
Sep 21, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[flutter_tools] add EPERM to set of immediate exit errors (#66159)
parent
cfe53fd3
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
84 additions
and
2 deletions
+84
-2
error_handling_io.dart
packages/flutter_tools/lib/src/base/error_handling_io.dart
+33
-1
error_handling_io_test.dart
...tools/test/general.shard/base/error_handling_io_test.dart
+51
-1
No files found.
packages/flutter_tools/lib/src/base/error_handling_io.dart
View file @
2c6f862b
...
...
@@ -297,6 +297,36 @@ class ErrorHandlingDirectory
);
}
@override
Future
<
Directory
>
create
({
bool
recursive
=
false
})
{
return
_run
<
Directory
>(
()
async
=>
wrap
(
await
delegate
.
create
(
recursive:
recursive
)),
platform:
_platform
,
failureMessage:
'Flutter failed to create a directory at "
${delegate.path}
"'
,
);
}
@override
Future
<
Directory
>
delete
({
bool
recursive
=
false
})
{
return
_run
<
Directory
>(
()
async
=>
wrap
(
fileSystem
.
directory
((
await
delegate
.
delete
(
recursive:
recursive
)).
path
)),
platform:
_platform
,
failureMessage:
'Flutter failed to delete a directory at "
${delegate.path}
"'
,
);
}
@override
void
deleteSync
({
bool
recursive
=
false
})
{
return
_runSync
<
void
>(
()
=>
delegate
.
deleteSync
(
recursive:
recursive
),
platform:
_platform
,
failureMessage:
'Flutter failed to delete a directory at "
${delegate.path}
"'
,
);
}
@override
String
toString
()
=>
delegate
.
toString
();
}
...
...
@@ -495,6 +525,7 @@ void _handlePosixException(Exception e, String message, int errorCode) {
// https://github.com/torvalds/linux/blob/master/include/uapi/asm-generic/errno.h
// https://github.com/torvalds/linux/blob/master/include/uapi/asm-generic/errno-base.h
// https://github.com/apple/darwin-xnu/blob/master/bsd/dev/dtrace/scripts/errno.d
const
int
eperm
=
1
;
const
int
enospc
=
28
;
const
int
eacces
=
13
;
// Catch errors and bail when:
...
...
@@ -506,9 +537,10 @@ void _handlePosixException(Exception e, String message, int errorCode) {
'Free up space and try again.'
,
);
break
;
case
eperm:
case
eacces:
throwToolExit
(
'
$message
. The flutter tool cannot access the file.
\n
'
'
$message
. The flutter tool cannot access the file
or directory
.
\n
'
'Please ensure that the SDK and/or project is installed in a location '
'that has read/write permissions for the current user.'
);
...
...
packages/flutter_tools/test/general.shard/base/error_handling_io_test.dart
View file @
2c6f862b
...
...
@@ -85,6 +85,14 @@ void setupDirectoryMocks({
.
thenThrow
(
FileSystemException
(
''
,
''
,
OSError
(
''
,
errorCode
)));
when
(
mockDirectory
.
createSync
(
recursive:
anyNamed
(
'recursive'
)))
.
thenThrow
(
FileSystemException
(
''
,
''
,
OSError
(
''
,
errorCode
)));
when
(
mockDirectory
.
create
())
.
thenThrow
(
FileSystemException
(
''
,
''
,
OSError
(
''
,
errorCode
)));
when
(
mockDirectory
.
createSync
())
.
thenThrow
(
FileSystemException
(
''
,
''
,
OSError
(
''
,
errorCode
)));
when
(
mockDirectory
.
delete
())
.
thenThrow
(
FileSystemException
(
''
,
''
,
OSError
(
''
,
errorCode
)));
when
(
mockDirectory
.
deleteSync
())
.
thenThrow
(
FileSystemException
(
''
,
''
,
OSError
(
''
,
errorCode
)));
}
void
main
(
)
{
...
...
@@ -198,6 +206,7 @@ void main() {
});
group
(
'throws ToolExit on Linux'
,
()
{
const
int
eperm
=
1
;
const
int
enospc
=
28
;
const
int
eacces
=
13
;
MockFileSystem
mockFileSystem
;
...
...
@@ -221,7 +230,7 @@ void main() {
final
File
file
=
fs
.
file
(
'file'
);
const
String
expectedMessage
=
'The flutter tool cannot access the file'
;
const
String
expectedMessage
=
'The flutter tool cannot access the file
or directory
'
;
expect
(()
async
=>
await
file
.
writeAsBytes
(<
int
>[
0
]),
throwsToolExit
(
message:
expectedMessage
));
expect
(()
async
=>
await
file
.
writeAsString
(
''
),
...
...
@@ -234,6 +243,26 @@ void main() {
throwsToolExit
(
message:
expectedMessage
));
});
testWithoutContext
(
'when access is denied for directories'
,
()
async
{
setupDirectoryMocks
(
mockFileSystem:
mockFileSystem
,
fs:
fs
,
errorCode:
eperm
,
);
final
Directory
directory
=
fs
.
directory
(
'file'
);
const
String
expectedMessage
=
'The flutter tool cannot access the file or directory'
;
expect
(()
async
=>
await
directory
.
create
(),
throwsToolExit
(
message:
expectedMessage
));
expect
(()
async
=>
await
directory
.
delete
(),
throwsToolExit
(
message:
expectedMessage
));
expect
(()
=>
directory
.
createSync
(),
throwsToolExit
(
message:
expectedMessage
));
expect
(()
=>
directory
.
deleteSync
(),
throwsToolExit
(
message:
expectedMessage
));
});
testWithoutContext
(
'when writing to a full device'
,
()
async
{
setupWriteMocks
(
mockFileSystem:
mockFileSystem
,
...
...
@@ -273,6 +302,7 @@ void main() {
group
(
'throws ToolExit on macOS'
,
()
{
const
int
eperm
=
1
;
const
int
enospc
=
28
;
const
int
eacces
=
13
;
MockFileSystem
mockFileSystem
;
...
...
@@ -309,6 +339,26 @@ void main() {
throwsToolExit
(
message:
expectedMessage
));
});
testWithoutContext
(
'when access is denied for directories'
,
()
async
{
setupDirectoryMocks
(
mockFileSystem:
mockFileSystem
,
fs:
fs
,
errorCode:
eperm
,
);
final
Directory
directory
=
fs
.
directory
(
'file'
);
const
String
expectedMessage
=
'The flutter tool cannot access the file or directory'
;
expect
(()
async
=>
await
directory
.
create
(),
throwsToolExit
(
message:
expectedMessage
));
expect
(()
async
=>
await
directory
.
delete
(),
throwsToolExit
(
message:
expectedMessage
));
expect
(()
=>
directory
.
createSync
(),
throwsToolExit
(
message:
expectedMessage
));
expect
(()
=>
directory
.
deleteSync
(),
throwsToolExit
(
message:
expectedMessage
));
});
testWithoutContext
(
'when writing to a full device'
,
()
async
{
setupWriteMocks
(
mockFileSystem:
mockFileSystem
,
...
...
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