protected function execute(InputInterface $input, OutputInterface $output) { $checksums = json_decode($this->fileChecksums, true); $root = __DIR__ . '/../'; $progressbar = new ProgressBar($output, count($checksums)); $errors = []; $missing = []; foreach ($checksums as $file => $checksum) { $progressbar->advance(); $absPath = Path::normalize($root . $file); if (!file_exists($absPath)) { $missing[] = $absPath; } elseif (md5(file_get_contents($absPath)) !== $checksum) { $errors[] = $absPath; } } $output->writeln("\n"); if (count($errors) > 0 || count($missing) > 0) { foreach ($missing as $path) { $output->writeln('<error>Missing file:</error> ' . $path); } foreach ($errors as $path) { $output->writeln('<error>Invalid checksum:</error> ' . $path); } $output->writeln("\nYour News installation does not " . 'match the recorded files and versions. This ' . 'is either caused by missing or old files or an ' . 'invalid or out of date appinfo/checksum.json ' . 'file.'); $output->writeln('Either way, please make sure that the contents ' . 'of the News app\'s directory match the ' . 'contents of the installed tarball.'); return 1; } else { $output->writeln('<info>Installation verified, everything OK!' . '</info>'); } }
// outputs 'foo/bar/baz' echo Path::join(['foo', 'bar', 'baz']) . PHP_EOL; // outputs 'foo/bar/baz' // The '.' and '..' directory references will be resolved in the paths echo Path::normalize('foo/./bar/../baz') . PHP_EOL; // outputs 'foo/baz' echo Path::join(['foo/./', 'bar', '../baz']) . PHP_EOL; // outputs 'foo/baz' // Only the first path can denote an absolute path in the join method echo Path::join('/foo', '/bar/baz') . PHP_EOL; // outputs '/foo/bar/baz' echo Path::join('foo', '/bar') . PHP_EOL; // outputs 'foo/bar' echo Path::join('foo', '../bar', 'baz') . PHP_EOL; // outputs 'bar/baz' echo Path::join('', '/bar', 'baz') . PHP_EOL; // outputs 'bar/baz' // Relative paths can start with a '..', but absolute paths cannot echo Path::join('/foo', '../../bar', 'baz') . PHP_EOL; // outputs '/bar/baz' echo Path::join('foo', '../../bar', 'baz') . PHP_EOL; // outputs '../bar/baz' // Empty path will result in a '.' echo Path::normalize('foo/..') . PHP_EOL; echo Path::join('foo', 'bar', '../..') . PHP_EOL; echo Path::normalize('/foo/bar') . PHP_EOL; // outputs 'C:\foo\Bar' echo Path::normalize('D:/foo/bar') . PHP_EOL; // outputs 'D:\foo\Bar' echo Path::normalize('/foo/bar', false) . PHP_EOL; // outputs '\foo\Bar'