@@ -26,27 +26,21 @@ |
||
26 | 26 | if ($localObjectModified) |
27 | 27 | { |
28 | 28 | $mergedIndex->addObject($localObject); |
29 | - } |
|
30 | - elseif ($remoteIndex === null) |
|
29 | + } elseif ($remoteIndex === null) |
|
31 | 30 | { |
32 | 31 | $mergedIndex->addObject($localObject); |
33 | 32 | } |
34 | - } |
|
35 | - else |
|
33 | + } else |
|
36 | 34 | { |
37 | 35 | $remoteObjectModified = $lastLocalIndex ? ($remoteObject->getMtime() > $lastLocalIndex->getCreated()->getTimestamp()) : false; |
38 | 36 | |
39 | 37 | if (!$localObjectModified) |
40 | 38 | { |
41 | 39 | $mergedIndex->addObject($remoteObject); |
42 | - } |
|
43 | - |
|
44 | - elseif (!$remoteObjectModified) |
|
40 | + } elseif (!$remoteObjectModified) |
|
45 | 41 | { |
46 | 42 | $mergedIndex->addObject($localObject); |
47 | - } |
|
48 | - |
|
49 | - else |
|
43 | + } else |
|
50 | 44 | { |
51 | 45 | throw new Exception("Collision at path {$localObject->getRelativePath()}"); |
52 | 46 | } |
@@ -29,8 +29,7 @@ discard block |
||
29 | 29 | { |
30 | 30 | throw new Exception(sprintf('read() failed for %s.', $relativePath)); |
31 | 31 | } |
32 | - } |
|
33 | - catch (FlysystemException $exception) |
|
32 | + } catch (FlysystemException $exception) |
|
34 | 33 | { |
35 | 34 | throw new Exception($exception->getMessage(), 0, $exception); |
36 | 35 | } |
@@ -48,8 +47,7 @@ discard block |
||
48 | 47 | { |
49 | 48 | throw new Exception(sprintf('write() failed for %s.', $relativePath)); |
50 | 49 | } |
51 | - } |
|
52 | - catch (FlysystemException $exception) |
|
50 | + } catch (FlysystemException $exception) |
|
53 | 51 | { |
54 | 52 | throw new Exception($exception->getMessage(), 0, $exception); |
55 | 53 | } |
@@ -65,8 +63,7 @@ discard block |
||
65 | 63 | { |
66 | 64 | throw new Exception(sprintf('writeStream() failed for %s.', $relativePath)); |
67 | 65 | } |
68 | - } |
|
69 | - catch (FlysystemException $exception) |
|
66 | + } catch (FlysystemException $exception) |
|
70 | 67 | { |
71 | 68 | throw new Exception($exception->getMessage(), 0, $exception); |
72 | 69 | } |
@@ -77,8 +74,7 @@ discard block |
||
77 | 74 | try |
78 | 75 | { |
79 | 76 | return $this->filesystem->has($relativePath); |
80 | - } |
|
81 | - catch (FlysystemException $exception) |
|
77 | + } catch (FlysystemException $exception) |
|
82 | 78 | { |
83 | 79 | throw new Exception($exception->getMessage(), 0, $exception); |
84 | 80 | } |
@@ -94,8 +90,7 @@ discard block |
||
94 | 90 | { |
95 | 91 | throw new Exception(sprintf('unlink() failed for %s', $relativePath)); |
96 | 92 | } |
97 | - } |
|
98 | - catch (FlysystemException $exception) |
|
93 | + } catch (FlysystemException $exception) |
|
99 | 94 | { |
100 | 95 | throw new Exception($exception->getMessage(), 0, $exception); |
101 | 96 | } |
@@ -113,8 +108,7 @@ discard block |
||
113 | 108 | } |
114 | 109 | |
115 | 110 | return $stream; |
116 | - } |
|
117 | - catch (FlysystemException $exception) |
|
111 | + } catch (FlysystemException $exception) |
|
118 | 112 | { |
119 | 113 | throw new Exception($exception->getMessage(), 0, $exception); |
120 | 114 | } |
@@ -29,8 +29,7 @@ |
||
29 | 29 | fclose($localStream); |
30 | 30 | |
31 | 31 | return true; |
32 | - } |
|
33 | - catch (Exception $exception) |
|
32 | + } catch (Exception $exception) |
|
34 | 33 | { |
35 | 34 | return false; |
36 | 35 | } |
@@ -157,17 +157,14 @@ |
||
157 | 157 | if (is_file($absolutePath)) |
158 | 158 | { |
159 | 159 | $object->type = static::TYPE_FILE; |
160 | - } |
|
161 | - elseif (is_dir($absolutePath)) |
|
160 | + } elseif (is_dir($absolutePath)) |
|
162 | 161 | { |
163 | 162 | $object->type = static::TYPE_DIR; |
164 | - } |
|
165 | - elseif (is_link($absolutePath)) |
|
163 | + } elseif (is_link($absolutePath)) |
|
166 | 164 | { |
167 | 165 | $object->type = static::TYPE_LINK; |
168 | 166 | $object->linkTarget = str_replace($basePath, '', readlink($absolutePath)); |
169 | - } |
|
170 | - else |
|
167 | + } else |
|
171 | 168 | { |
172 | 169 | throw new Exception(sprintf('File %s does not exist!', $absolutePath)); |
173 | 170 | } |
@@ -38,8 +38,7 @@ |
||
38 | 38 | if ($parent === null) |
39 | 39 | { |
40 | 40 | throw new Exception(); |
41 | - } |
|
42 | - elseif (!$parent->isDirectory()) |
|
41 | + } elseif (!$parent->isDirectory()) |
|
43 | 42 | { |
44 | 43 | throw new Exception(); |
45 | 44 | } |
@@ -110,8 +110,7 @@ |
||
110 | 110 | if (count($operationCollection)) |
111 | 111 | { |
112 | 112 | $output->writeln(sprintf('Current state: <bold>There are %d outstanding operations.</bold>', count($operationCollection))); |
113 | - } |
|
114 | - else |
|
113 | + } else |
|
115 | 114 | { |
116 | 115 | $output->writeln('Current state: <info>Everything is up to date!</info>'); |
117 | 116 | } |
@@ -46,8 +46,7 @@ |
||
46 | 46 | if ($input->getOption('config')) |
47 | 47 | { |
48 | 48 | $this->config = $reader->getConfiguration($input->getOption('config')); |
49 | - } |
|
50 | - elseif (is_file('archivr.json')) |
|
49 | + } elseif (is_file('archivr.json')) |
|
51 | 50 | { |
52 | 51 | $this->config = $reader->getConfiguration('archivr.json'); |
53 | 52 | } |
@@ -4,7 +4,7 @@ |
||
4 | 4 | |
5 | 5 | class Application extends \Symfony\Component\Console\Application |
6 | 6 | { |
7 | - const LOGO = <<<TXT |
|
7 | + const LOGO = <<<TXT |
|
8 | 8 | ___ __ _ ___ |
9 | 9 | / _ | ________/ / (_) __/ _ \ |
10 | 10 | / __ |/ __/ __/ _ \/ / |/ / , _/ |
@@ -681,6 +681,9 @@ discard block |
||
681 | 681 | return $operationCollection; |
682 | 682 | } |
683 | 683 | |
684 | + /** |
|
685 | + * @param resource $stream |
|
686 | + */ |
|
684 | 687 | protected function readIndexFromStream($stream, \DateTime $created = null): Index |
685 | 688 | { |
686 | 689 | if (!is_resource($stream)) |
@@ -715,6 +718,9 @@ discard block |
||
715 | 718 | fclose($stream); |
716 | 719 | } |
717 | 720 | |
721 | + /** |
|
722 | + * @param resource $stream |
|
723 | + */ |
|
718 | 724 | protected function readSynchronizationListFromStream($stream): SynchronizationList |
719 | 725 | { |
720 | 726 | if (!is_resource($stream)) |
@@ -299,8 +299,7 @@ discard block |
||
299 | 299 | { |
300 | 300 | $newRevision = $newRevision ?: ($lastSynchronization->getRevision() + 1); |
301 | 301 | $remoteIndex = $this->doLoadRemoteIndex($lastSynchronization->getRevision(), $synchronizationList); |
302 | - } |
|
303 | - else |
|
302 | + } else |
|
304 | 303 | { |
305 | 304 | $newRevision = $newRevision ?: 1; |
306 | 305 | $remoteIndex = null; |
@@ -432,12 +431,10 @@ discard block |
||
432 | 431 | try |
433 | 432 | { |
434 | 433 | return $this->doRestore($revision, $progressListener, true); |
435 | - } |
|
436 | - catch (\Exception $exception) |
|
434 | + } catch (\Exception $exception) |
|
437 | 435 | { |
438 | 436 | throw $exception; |
439 | - } |
|
440 | - finally |
|
437 | + } finally |
|
441 | 438 | { |
442 | 439 | $this->localPath = $originalLocalPath; |
443 | 440 | } |
@@ -602,9 +599,7 @@ discard block |
||
602 | 599 | $directoryMtimes[$absoluteLocalPath] = $mergedIndexObject->getMtime(); |
603 | 600 | } |
604 | 601 | } |
605 | - } |
|
606 | - |
|
607 | - elseif ($mergedIndexObject->isFile()) |
|
602 | + } elseif ($mergedIndexObject->isFile()) |
|
608 | 603 | { |
609 | 604 | // local file did not exist, hasn't been a file before or is outdated |
610 | 605 | $doDownloadFile = $localObject === null || !$localObject->isFile() || $localObject->getMtime() < $mergedIndexObject->getMtime(); |
@@ -635,9 +630,7 @@ discard block |
||
635 | 630 | |
636 | 631 | $operationCollection->addOperation(new UploadOperation($absoluteLocalPath, $mergedIndexObject->getBlobId(), $this->vaultConnection, $uploadStreamFilters)); |
637 | 632 | } |
638 | - } |
|
639 | - |
|
640 | - elseif ($mergedIndexObject->isLink()) |
|
633 | + } elseif ($mergedIndexObject->isLink()) |
|
641 | 634 | { |
642 | 635 | $absoluteLinkTarget = dirname($absoluteLocalPath) . DIRECTORY_SEPARATOR . $mergedIndexObject->getLinkTarget(); |
643 | 636 | |
@@ -646,9 +639,7 @@ discard block |
||
646 | 639 | $operationCollection->addOperation(new UnlinkOperation($absoluteLocalPath)); |
647 | 640 | $operationCollection->addOperation(new SymlinkOperation($absoluteLocalPath, $absoluteLinkTarget, $mergedIndexObject->getMode())); |
648 | 641 | } |
649 | - } |
|
650 | - |
|
651 | - else |
|
642 | + } else |
|
652 | 643 | { |
653 | 644 | // unknown/invalid object type |
654 | 645 | throw new Exception(); |