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
8de72126
Unverified
Commit
8de72126
authored
Nov 25, 2020
by
Jia Hao
Committed by
GitHub
Nov 25, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[flutter_tools] Don't fail copying files if the destination is not writable (#71215)
parent
9806865b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
6 deletions
+21
-6
error_handling_io.dart
packages/flutter_tools/lib/src/base/error_handling_io.dart
+1
-4
error_handling_io_test.dart
...tools/test/general.shard/base/error_handling_io_test.dart
+20
-2
No files found.
packages/flutter_tools/lib/src/base/error_handling_io.dart
View file @
8de72126
...
@@ -289,10 +289,7 @@ class ErrorHandlingFile
...
@@ -289,10 +289,7 @@ class ErrorHandlingFile
// Next check if the destination file can be written. If not, bail through
// Next check if the destination file can be written. If not, bail through
// error handling.
// error handling.
_runSync
<
void
>(
_runSync
<
void
>(
()
{
()
=>
resultFile
.
createSync
(
recursive:
true
),
resultFile
.
createSync
(
recursive:
true
);
resultFile
.
openSync
(
mode:
FileMode
.
writeOnly
).
closeSync
();
},
platform:
_platform
,
platform:
_platform
,
failureMessage:
'Flutter failed to copy
$path
to
$newPath
due to destination location error'
failureMessage:
'Flutter failed to copy
$path
to
$newPath
due to destination location error'
);
);
...
...
packages/flutter_tools/test/general.shard/base/error_handling_io_test.dart
View file @
8de72126
...
@@ -817,12 +817,12 @@ void main() {
...
@@ -817,12 +817,12 @@ void main() {
expect
(()
=>
fileSystem
.
file
(
'source'
).
copySync
(
'dest'
),
throwsToolExit
());
expect
(()
=>
fileSystem
.
file
(
'source'
).
copySync
(
'dest'
),
throwsToolExit
());
});
});
testWithoutContext
(
'copySync handles error if
open
Sync on destination file fails'
,
()
{
testWithoutContext
(
'copySync handles error if
create
Sync on destination file fails'
,
()
{
final
MockFile
source
=
MockFile
();
final
MockFile
source
=
MockFile
();
final
MockFile
dest
=
MockFile
();
final
MockFile
dest
=
MockFile
();
when
(
source
.
openSync
(
mode:
anyNamed
(
'mode'
)))
when
(
source
.
openSync
(
mode:
anyNamed
(
'mode'
)))
.
thenReturn
(
MockRandomAccessFile
());
.
thenReturn
(
MockRandomAccessFile
());
when
(
dest
.
openSync
(
mode:
anyNamed
(
'mod
e'
)))
when
(
dest
.
createSync
(
recursive:
anyNamed
(
'recursiv
e'
)))
.
thenThrow
(
const
FileSystemException
(
''
,
''
,
OSError
(
''
,
eaccess
)));
.
thenThrow
(
const
FileSystemException
(
''
,
''
,
OSError
(
''
,
eaccess
)));
when
(
mockFileSystem
.
file
(
'source'
)).
thenReturn
(
source
);
when
(
mockFileSystem
.
file
(
'source'
)).
thenReturn
(
source
);
when
(
mockFileSystem
.
file
(
'dest'
)).
thenReturn
(
dest
);
when
(
mockFileSystem
.
file
(
'dest'
)).
thenReturn
(
dest
);
...
@@ -830,6 +830,24 @@ void main() {
...
@@ -830,6 +830,24 @@ void main() {
expect
(()
=>
fileSystem
.
file
(
'source'
).
copySync
(
'dest'
),
throwsToolExit
());
expect
(()
=>
fileSystem
.
file
(
'source'
).
copySync
(
'dest'
),
throwsToolExit
());
});
});
// dart:io is able to clobber read-only files.
testWithoutContext
(
'copySync will copySync even if the destination is not writable'
,
()
{
final
MockFile
source
=
MockFile
();
final
MockFile
dest
=
MockFile
();
when
(
source
.
copySync
(
any
)).
thenReturn
(
dest
);
when
(
mockFileSystem
.
file
(
'source'
)).
thenReturn
(
source
);
when
(
source
.
openSync
(
mode:
anyNamed
(
'mode'
)))
.
thenReturn
(
MockRandomAccessFile
());
when
(
mockFileSystem
.
file
(
'dest'
)).
thenReturn
(
dest
);
when
(
dest
.
openSync
(
mode:
FileMode
.
writeOnly
))
.
thenThrow
(
const
FileSystemException
(
''
,
''
,
OSError
(
''
,
eaccess
)));
fileSystem
.
file
(
'source'
).
copySync
(
'dest'
);
verify
(
source
.
copySync
(
'dest'
)).
called
(
1
);
});
testWithoutContext
(
'copySync will copySync if there are no exceptions'
,
()
{
testWithoutContext
(
'copySync will copySync if there are no exceptions'
,
()
{
final
MockFile
source
=
MockFile
();
final
MockFile
source
=
MockFile
();
final
MockFile
dest
=
MockFile
();
final
MockFile
dest
=
MockFile
();
...
...
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