Commit c00d61f6 authored by Devon Carew's avatar Devon Carew

have flutter precache print if there's no work to do (#3213)

* have flutter precache print if there's no work to do

* tweak precache
parent f8c1d619
......@@ -38,19 +38,29 @@ class Cache {
return new Directory(path.join(getCacheArtifacts().path, name));
}
String getVersionFor(String kArtifactName) {
File versionFile = new File(path.join(getRoot().path, '$kArtifactName.version'));
String getVersionFor(String artifactName) {
File versionFile = new File(path.join(getRoot().path, '$artifactName.version'));
return versionFile.existsSync() ? versionFile.readAsStringSync().trim() : null;
}
String getStampFor(String kArtifactName) {
File stampFile = new File(path.join(getRoot().path, '$kArtifactName.stamp'));
String getStampFor(String artifactName) {
File stampFile = getStampFileFor(artifactName);
return stampFile.existsSync() ? stampFile.readAsStringSync().trim() : null;
}
void setStampFor(String kArtifactName, String version) {
File stampFile = new File(path.join(getRoot().path, '$kArtifactName.stamp'));
stampFile.writeAsStringSync(version);
void setStampFor(String artifactName, String version) {
getStampFileFor(artifactName).writeAsStringSync(version);
}
File getStampFileFor(String artifactName) {
return new File(path.join(getRoot().path, '$artifactName.stamp'));
}
bool isUpToDate() {
MaterialFonts materialFonts = new MaterialFonts(cache);
FlutterEngine engine = new FlutterEngine(cache);
return materialFonts.isUpToDate() && engine.isUpToDate();
}
Future<String> getThirdPartyFile(String urlStr, String serviceName, {
......
......@@ -6,7 +6,7 @@ import 'dart:async';
import 'package:args/command_runner.dart';
import '../cache.dart';
import '../globals.dart';
class PrecacheCommand extends Command {
@override
......@@ -17,7 +17,11 @@ class PrecacheCommand extends Command {
@override
Future<int> run() async {
await Cache.instance.updateAll();
if (cache.isUpToDate())
printStatus('All up-to-date.');
else
await cache.updateAll();
return 0;
}
}
......@@ -18,7 +18,7 @@ bool _shouldRunPubGet({ File pubSpecYaml, File dotPackages }) {
DateTime dotPackagesLastModified = dotPackages.lastModifiedSync();
if (pubSpecYaml.lastModifiedSync().isAfter(dotPackagesLastModified))
return true;
File flutterToolsStamp = new File(path.join(Cache.instance.getRoot().path, 'flutter_tools.stamp'));
File flutterToolsStamp = Cache.instance.getStampFileFor('flutter_tools');
if (flutterToolsStamp.lastModifiedSync().isAfter(dotPackagesLastModified))
return true;
return false;
......
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