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
4d490666
Commit
4d490666
authored
Jun 22, 2017
by
Zachary Anderson
Committed by
GitHub
Jun 22, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Clean up pre-existing DevFS during creation (#10843)
parent
02245234
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
71 additions
and
6 deletions
+71
-6
fuchsia_reload.dart
packages/flutter_tools/lib/src/commands/fuchsia_reload.dart
+15
-0
devfs.dart
packages/flutter_tools/lib/src/devfs.dart
+13
-5
devfs_test.dart
packages/flutter_tools/test/devfs_test.dart
+43
-1
No files found.
packages/flutter_tools/lib/src/commands/fuchsia_reload.dart
View file @
4d490666
...
...
@@ -143,9 +143,24 @@ class FuchsiaReloadCommand extends FlutterCommand {
return
_vmServiceCache
[
port
];
}
Future
<
bool
>
_checkPort
(
int
port
)
async
{
bool
connected
=
true
;
Socket
s
;
try
{
s
=
await
Socket
.
connect
(
"
$_address
"
,
port
);
}
catch
(
_
)
{
connected
=
false
;
}
if
(
s
!=
null
)
await
s
.
close
();
return
connected
;
}
Future
<
List
<
FlutterView
>>
_getViews
(
List
<
int
>
ports
)
async
{
final
List
<
FlutterView
>
views
=
<
FlutterView
>[];
for
(
int
port
in
ports
)
{
if
(!
await
_checkPort
(
port
))
continue
;
final
VMService
vmService
=
_getVMService
(
port
);
await
vmService
.
getVM
();
await
vmService
.
waitForViews
();
...
...
packages/flutter_tools/lib/src/devfs.dart
View file @
4d490666
...
...
@@ -5,6 +5,8 @@
import
'dart:async'
;
import
'dart:convert'
show
BASE64
,
UTF8
;
import
'package:json_rpc_2/json_rpc_2.dart'
as
rpc
;
import
'asset.dart'
;
import
'base/context.dart'
;
import
'base/file_system.dart'
;
...
...
@@ -185,10 +187,7 @@ class ServiceProtocolDevFSOperations implements DevFSOperations {
@override
Future
<
dynamic
>
destroy
(
String
fsName
)
async
{
await
vmService
.
vm
.
invokeRpcRaw
(
'_deleteDevFS'
,
params:
<
String
,
dynamic
>
{
'fsName'
:
fsName
},
);
await
vmService
.
vm
.
deleteDevFS
(
fsName
);
}
@override
...
...
@@ -352,7 +351,16 @@ class DevFS {
Future
<
Uri
>
create
()
async
{
printTrace
(
'DevFS: Creating new filesystem on the device (
$_baseUri
)'
);
_baseUri
=
await
_operations
.
create
(
fsName
);
try
{
_baseUri
=
await
_operations
.
create
(
fsName
);
}
on
rpc
.
RpcException
catch
(
rpcException
)
{
// 1001 is kFileSystemAlreadyExists in //dart/runtime/vm/json_stream.h
if
(
rpcException
.
code
!=
1001
)
rethrow
;
printTrace
(
'DevFS: Creating failed. Destroying and trying again'
);
await
destroy
();
_baseUri
=
await
_operations
.
create
(
fsName
);
}
printTrace
(
'DevFS: Created new filesystem on the device (
$_baseUri
)'
);
return
_baseUri
;
}
...
...
packages/flutter_tools/test/devfs_test.dart
View file @
4d490666
...
...
@@ -13,6 +13,7 @@ import 'package:flutter_tools/src/base/file_system.dart';
import
'package:flutter_tools/src/build_info.dart'
;
import
'package:flutter_tools/src/devfs.dart'
;
import
'package:flutter_tools/src/vmservice.dart'
;
import
'package:json_rpc_2/json_rpc_2.dart'
as
rpc
;
import
'package:test/test.dart'
;
import
'src/common.dart'
;
...
...
@@ -335,7 +336,34 @@ void main() {
testUsingContext
(
'delete dev file system'
,
()
async
{
expect
(
vmService
.
messages
,
isEmpty
,
reason:
'prior test timeout'
);
await
devFS
.
destroy
();
vmService
.
expectMessages
(<
String
>[
'_deleteDevFS {fsName: test}'
]);
vmService
.
expectMessages
(<
String
>[
'destroy test'
]);
expect
(
devFS
.
assetPathsToEvict
,
isEmpty
);
},
overrides:
<
Type
,
Generator
>{
FileSystem:
()
=>
fs
,
});
testUsingContext
(
'cleanup preexisting file system'
,
()
async
{
// simulate workspace
final
File
file
=
fs
.
file
(
fs
.
path
.
join
(
basePath
,
filePath
));
await
file
.
parent
.
create
(
recursive:
true
);
file
.
writeAsBytesSync
(<
int
>[
1
,
2
,
3
]);
// simulate package
await
_createPackage
(
fs
,
'somepkg'
,
'somefile.txt'
);
devFS
=
new
DevFS
(
vmService
,
'test'
,
tempDir
);
await
devFS
.
create
();
vmService
.
expectMessages
(<
String
>[
'create test'
]);
expect
(
devFS
.
assetPathsToEvict
,
isEmpty
);
// Try to create again.
await
devFS
.
create
();
vmService
.
expectMessages
(<
String
>[
'create test'
,
'destroy test'
,
'create test'
]);
expect
(
devFS
.
assetPathsToEvict
,
isEmpty
);
// Really destroy.
await
devFS
.
destroy
();
vmService
.
expectMessages
(<
String
>[
'destroy test'
]);
expect
(
devFS
.
assetPathsToEvict
,
isEmpty
);
},
overrides:
<
Type
,
Generator
>{
FileSystem:
()
=>
fs
,
...
...
@@ -390,15 +418,29 @@ class MockVMService extends BasicMock implements VMService {
class
MockVM
implements
VM
{
final
MockVMService
_service
;
final
Uri
_baseUri
=
Uri
.
parse
(
'file:///tmp/devfs/test'
);
bool
_devFSExists
=
false
;
static
const
int
kFileSystemAlreadyExists
=
1001
;
MockVM
(
this
.
_service
);
@override
Future
<
Map
<
String
,
dynamic
>>
createDevFS
(
String
fsName
)
async
{
_service
.
messages
.
add
(
'create
$fsName
'
);
if
(
_devFSExists
)
{
throw
new
rpc
.
RpcException
(
kFileSystemAlreadyExists
,
'File system already exists'
);
}
_devFSExists
=
true
;
return
<
String
,
dynamic
>{
'uri'
:
'
$_baseUri
'
};
}
@override
Future
<
Map
<
String
,
dynamic
>>
deleteDevFS
(
String
fsName
)
async
{
_service
.
messages
.
add
(
'destroy
$fsName
'
);
_devFSExists
=
false
;
return
<
String
,
dynamic
>{
'type'
:
'Success'
};
}
@override
Future
<
Map
<
String
,
dynamic
>>
invokeRpcRaw
(
String
method
,
{
Map
<
String
,
dynamic
>
params:
const
<
String
,
dynamic
>{},
...
...
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