Read ahead: resolve paths before opening connections; a failing readAhead() leaves no spool folder
This commit is contained in:
@@ -257,6 +257,8 @@ final class StorageBackend implements IBackend, IReadsAhead {
|
|||||||
if (!$this->sftpReads || $reconnect === null || $ranges === []) {
|
if (!$this->sftpReads || $reconnect === null || $ranges === []) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
// before any connection is opened: an invalid path throws
|
||||||
|
$abs = array_map(fn (array $r): array => [$this->abs($r[0]), $r[1], $r[2]], $ranges);
|
||||||
$storages = [];
|
$storages = [];
|
||||||
$connections = [];
|
$connections = [];
|
||||||
$root = '';
|
$root = '';
|
||||||
@@ -277,7 +279,6 @@ final class StorageBackend implements IBackend, IReadsAhead {
|
|||||||
if ($connections === []) {
|
if ($connections === []) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
$abs = array_map(fn (array $r): array => [$this->abs($r[0]), $r[1], $r[2]], $ranges);
|
|
||||||
return (static function () use ($storages, $connections, $root, $abs, $spool): \Generator {
|
return (static function () use ($storages, $connections, $root, $abs, $spool): \Generator {
|
||||||
// the storages hold their connections: kept until the fetcher is done
|
// the storages hold their connections: kept until the fetcher is done
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -254,7 +254,11 @@ final class Repository {
|
|||||||
if (count($plan->ranges()) < 2 || (!is_dir($plan->spool) && !@mkdir($plan->spool, 0700, true))) {
|
if (count($plan->ranges()) < 2 || (!is_dir($plan->spool) && !@mkdir($plan->spool, 0700, true))) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
$streams = $this->backend->readAhead($plan->ranges(), $plan->spool);
|
try {
|
||||||
|
$streams = $this->backend->readAhead($plan->ranges(), $plan->spool);
|
||||||
|
} catch (\Throwable) {
|
||||||
|
$streams = null; // the usual reads report what is wrong
|
||||||
|
}
|
||||||
if ($streams === null) {
|
if ($streams === null) {
|
||||||
@rmdir($plan->spool);
|
@rmdir($plan->spool);
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
Reference in New Issue
Block a user