Commit 0a9ff388 authored by Dan Field's avatar Dan Field Committed by Flutter GitHub Bot

Revert "Use platform appropriate filepaths" (#47395)

parent d51956a9
...@@ -34,7 +34,7 @@ Future<Depfile> copyAssets(Environment environment, Directory outputDirectory) a ...@@ -34,7 +34,7 @@ Future<Depfile> copyAssets(Environment environment, Directory outputDirectory) a
assetBundle.entries.entries.map<Future<void>>((MapEntry<String, DevFSContent> entry) async { assetBundle.entries.entries.map<Future<void>>((MapEntry<String, DevFSContent> entry) async {
final PoolResource resource = await pool.request(); final PoolResource resource = await pool.request();
try { try {
final File file = fs.file(outputDirectory.uri.resolve(entry.key)); final File file = fs.file(fs.path.join(outputDirectory.path, entry.key));
outputs.add(file); outputs.add(file);
file.parent.createSync(recursive: true); file.parent.createSync(recursive: true);
final DevFSContent content = entry.value; final DevFSContent content = entry.value;
......
...@@ -195,7 +195,7 @@ Future<void> writeBundle( ...@@ -195,7 +195,7 @@ Future<void> writeBundle(
assetEntries.entries.map<Future<void>>((MapEntry<String, DevFSContent> entry) async { assetEntries.entries.map<Future<void>>((MapEntry<String, DevFSContent> entry) async {
final PoolResource resource = await pool.request(); final PoolResource resource = await pool.request();
try { try {
final File file = fs.file(bundleDir.uri.resolve(entry.key)); final File file = fs.file(fs.path.join(bundleDir.path, entry.key));
file.parent.createSync(recursive: true); file.parent.createSync(recursive: true);
await file.writeAsBytes(await entry.value.contentsAsBytes()); await file.writeAsBytes(await entry.value.contentsAsBytes());
} finally { } finally {
......
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
import 'dart:io';
import 'package:flutter_tools/src/base/file_system.dart'; import 'package:flutter_tools/src/base/file_system.dart';
import 'package:flutter_tools/src/build_system/build_system.dart'; import 'package:flutter_tools/src/build_system/build_system.dart';
import 'package:flutter_tools/src/build_system/targets/assets.dart'; import 'package:flutter_tools/src/build_system/targets/assets.dart';
...@@ -25,6 +27,8 @@ void main() { ...@@ -25,6 +27,8 @@ void main() {
..createSync(recursive: true); ..createSync(recursive: true);
fs.file(fs.path.join('assets', 'foo', 'bar.png')) fs.file(fs.path.join('assets', 'foo', 'bar.png'))
..createSync(recursive: true); ..createSync(recursive: true);
fs.file(fs.path.join('assets', 'wildcard', '#bar.png'))
..createSync(recursive: true);
fs.file('.packages') fs.file('.packages')
..createSync(); ..createSync();
fs.file('pubspec.yaml') fs.file('pubspec.yaml')
...@@ -35,6 +39,7 @@ name: example ...@@ -35,6 +39,7 @@ name: example
flutter: flutter:
assets: assets:
- assets/foo/bar.png - assets/foo/bar.png
- assets/wildcard/
'''); ''');
}); });
}); });
...@@ -45,14 +50,16 @@ flutter: ...@@ -45,14 +50,16 @@ flutter:
expect(fs.file(fs.path.join(environment.buildDir.path, 'flutter_assets', 'AssetManifest.json')).existsSync(), true); expect(fs.file(fs.path.join(environment.buildDir.path, 'flutter_assets', 'AssetManifest.json')).existsSync(), true);
expect(fs.file(fs.path.join(environment.buildDir.path, 'flutter_assets', 'FontManifest.json')).existsSync(), true); expect(fs.file(fs.path.join(environment.buildDir.path, 'flutter_assets', 'FontManifest.json')).existsSync(), true);
expect(fs.file(fs.path.join(environment.buildDir.path, 'flutter_assets', 'LICENSE')).existsSync(), true); expect(fs.file(fs.path.join(environment.buildDir.path, 'flutter_assets', 'LICENSE')).existsSync(), true);
expect(fs.file(fs.path.join(environment.buildDir.path, 'flutter_assets', 'assets', 'foo', 'bar.png')).existsSync(), true); // See https://github.com/flutter/flutter/issues/35293
expect(fs.file(fs.path.join(environment.buildDir.path, 'flutter_assets', 'assets/foo/bar.png')).existsSync(), true);
// See https://github.com/flutter/flutter/issues/46163
expect(fs.file(fs.path.join(environment.buildDir.path, 'flutter_assets', 'assets/wildcard/%23bar.png')).existsSync(), true);
})); }));
test('Does not leave stale files in build directory', () => testbed.run(() async { test('Does not leave stale files in build directory', () => testbed.run(() async {
await buildSystem.build(const CopyAssets(), environment); await buildSystem.build(const CopyAssets(), environment);
final File assetFile = fs.file(fs.path.join(environment.buildDir.path, 'flutter_assets', 'assets', 'foo', 'bar.png'));
expect(assetFile.existsSync(), true); expect(fs.file(fs.path.join(environment.buildDir.path, 'flutter_assets', 'assets/foo/bar.png')).existsSync(), true);
// Modify manifest to remove asset. // Modify manifest to remove asset.
fs.file('pubspec.yaml') fs.file('pubspec.yaml')
..createSync() ..createSync()
...@@ -63,8 +70,9 @@ flutter: ...@@ -63,8 +70,9 @@ flutter:
'''); ''');
await buildSystem.build(const CopyAssets(), environment); await buildSystem.build(const CopyAssets(), environment);
expect(assetFile.existsSync(), false); // See https://github.com/flutter/flutter/issues/35293
})); expect(fs.file(fs.path.join(environment.buildDir.path, 'flutter_assets', 'assets/foo/bar.png')).existsSync(), false);
}), skip: Platform.isWindows); // See https://github.com/google/file.dart/issues/131
test('FlutterPlugins updates required files as needed', () => testbed.run(() async { test('FlutterPlugins updates required files as needed', () => testbed.run(() async {
fs.file('pubspec.yaml') fs.file('pubspec.yaml')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment