Dont crash if the tool cannot delete asset directory during debugging (#45407)

This commit is contained in:
Jonah Williams
2019-11-22 14:06:05 -08:00
committed by GitHub
parent 35b571ccfc
commit b54bb6abbb
2 changed files with 29 additions and 1 deletions

View File

@@ -10,6 +10,7 @@ import 'package:pool/pool.dart';
import 'asset.dart';
import 'base/common.dart';
import 'base/file_system.dart';
import 'base/logger.dart';
import 'build_info.dart';
import 'build_system/build_system.dart';
import 'build_system/depfile.dart';
@@ -173,9 +174,18 @@ Future<AssetBundle> buildAssets({
Future<void> writeBundle(
Directory bundleDir,
Map<String, DevFSContent> assetEntries,
{ Logger loggerOverride }
) async {
loggerOverride ??= logger;
if (bundleDir.existsSync()) {
bundleDir.deleteSync(recursive: true);
try {
bundleDir.deleteSync(recursive: true);
} on FileSystemException catch (err) {
loggerOverride.printError(
'Failed to clean up asset directory ${bundleDir.path}: $err\n'
'To clean build artifacts, use the command "flutter clean".'
);
}
}
bundleDir.createSync(recursive: true);