-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathcheck.php
54 lines (40 loc) · 1.54 KB
/
check.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<?php
use ProgressBar\Manager as ProgressBarManager;
require_once __DIR__ . '/vendor/autoload.php';
/**
* ダウンロードに失敗したファイルを一覧で出す
*/
if (file_exists(__DIR__ . '/config.php')) {
$config = require __DIR__ . '/config.php';
} else {
$config = require __DIR__ . '/config.default.php';
}
$cachedir = $config->cachedir;
$packagejson = json_decode(file_get_contents($cachedir.'packages.json'));
$j = 0;
$errors = array();
$providerCounter = 1;
$numberOfProviders = count( (array)$packagejson->{'provider-includes'} );
foreach ($packagejson->{'provider-includes'} as $tpl => $provider) {
$providerjson = str_replace('%hash%', $provider->sha256, $tpl);
$packages = json_decode(file_get_contents($cachedir.$providerjson));
$progressBar = new ProgressBarManager(0, count( (array)$packages->providers ));
$progressBar->setFormat(" - Package: %current%/%max% [%bar%] %percent%%");
echo " - Check Provider {$providerCounter}/{$numberOfProviders}:\n";
foreach ($packages->providers as $tpl2 => $sha) {
if (!file_exists($file = $cachedir . "p/$tpl2\$$sha->sha256.json")) {
$errors[] = " - $tpl\t$tpl2 file not exists\n";
} elseif ($sha->sha256 !== hash_file('sha256', $file)) {
unlink($file);
$errors[] = " - $tpl\t$tpl2\tsha256 not match: {$sha->sha256}\n";
} else {
++$j;
}
$progressBar->advance();
}
++$providerCounter;
}
if (count($errors)) {
echo "Errors: \n", implode('', $errors);
}
exit(1);