[flutter_tools] do not set timestamp of package_config file (#57077)

This commit is contained in:
Jonah Williams
2020-05-14 11:12:08 -07:00
committed by GitHub
parent b4788f290c
commit 8a77381e58
2 changed files with 1 additions and 20 deletions

View File

@@ -223,7 +223,7 @@ class _DefaultPub implements Pub {
}
if (!packageConfigFile.existsSync()) {
throwToolExit('$directory: pub did not create .packages file.');
throwToolExit('$directory: pub did not create .dart_tools/package_config.json file.');
}
if (pubSpecYaml.lastModifiedSync() != originalPubspecYamlModificationTime) {
throwToolExit(
@@ -232,8 +232,6 @@ class _DefaultPub implements Pub {
}
// We don't check if dotPackages was actually modified, because as far as we can tell sometimes
// pub will decide it does not need to actually modify it.
// Since we rely on the file having a more recent timestamp, though, we do manually force the
// file to be more recently modified.
final DateTime now = DateTime.now();
if (now.isBefore(originalPubspecYamlModificationTime)) {
_logger.printError(
@@ -243,18 +241,6 @@ class _DefaultPub implements Pub {
'The timestamp was: $originalPubspecYamlModificationTime\n'
'The time now is: $now'
);
} else {
packageConfigFile.setLastModifiedSync(now);
final DateTime newDotPackagesTimestamp = packageConfigFile.lastModifiedSync();
if (newDotPackagesTimestamp.isBefore(originalPubspecYamlModificationTime)) {
_logger.printError(
'Warning: Failed to set timestamp of "${_fileSystem.path.absolute(packageConfigFile.path)}". '
'Tried to set timestamp to $now, but new timestamp is $newDotPackagesTimestamp.'
);
if (newDotPackagesTimestamp.isAfter(now)) {
_logger.printError('Maybe the file was concurrently modified?');
}
}
}
}