mirror of
https://github.com/demostf/migrate.git
synced 2026-06-04 01:34:12 +02:00
attempt to re-download demos with invalid hash
This commit is contained in:
parent
c76de9362a
commit
9fd4b88d8d
1 changed files with 16 additions and 1 deletions
|
|
@ -24,7 +24,7 @@ class Migrate {
|
||||||
$hash = $this->store->hash($name);
|
$hash = $this->store->hash($name);
|
||||||
|
|
||||||
if ($hash !== $demo['hash']) {
|
if ($hash !== $demo['hash']) {
|
||||||
throw new \Exception('hash mismatch: ' . $this->store->generatePath($name));
|
$this->reDownloadDemo($demo);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->api->changeDemo(
|
return $this->api->changeDemo(
|
||||||
|
|
@ -36,4 +36,19 @@ class Migrate {
|
||||||
$this->key
|
$this->key
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function reDownloadDemo(array $demo) {
|
||||||
|
$name = basename($demo['url']);
|
||||||
|
|
||||||
|
$tmpFile = tempnam(sys_get_temp_dir(), 'dem_');
|
||||||
|
copy($demo['url'], $tmpFile);
|
||||||
|
|
||||||
|
$newHash = md5_file($tmpFile);
|
||||||
|
if ($newHash !== $demo['hash']) {
|
||||||
|
throw new \Exception('hash mismatch even after re-download: ' . $this->store->generatePath($name));
|
||||||
|
}
|
||||||
|
|
||||||
|
unlink($this->store->generatePath($name));
|
||||||
|
rename($tmpFile, $this->store->generatePath($name));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue