|
3 | 3 |
|
4 | 4 | use phpbu\App\Backup\Target; |
5 | 5 | use phpbu\App\Cli\Executable; |
| 6 | +use phpbu\App\Configuration; |
6 | 7 | use phpbu\App\Exception; |
7 | 8 | use phpbu\App\Result; |
8 | 9 | use phpbu\App\Util; |
| 10 | +use Symfony\Component\Finder\Tests\Iterator\FilecontentFilterIteratorTest; |
9 | 11 |
|
10 | 12 | /** |
11 | 13 | * Tar source class. |
@@ -111,18 +113,32 @@ class Tar extends SimulatorExecutable implements Simulator |
111 | 113 | */ |
112 | 114 | public function setup(array $conf = []) |
113 | 115 | { |
| 116 | + $this->setupPath($conf); |
114 | 117 | $this->pathToTar = Util\Arr::getValue($conf, 'pathToTar', ''); |
115 | | - $this->path = Util\Arr::getValue($conf, 'path', ''); |
116 | 118 | $this->excludes = Util\Str::toList(Util\Arr::getValue($conf, 'exclude', '')); |
117 | 119 | $this->compressProgram = Util\Arr::getValue($conf, 'compressProgram', ''); |
118 | 120 | $this->throttle = Util\Arr::getValue($conf, 'throttle', ''); |
119 | 121 | $this->forceLocal = Util\Str::toBoolean(Util\Arr::getValue($conf, 'forceLocal', ''), false); |
120 | 122 | $this->ignoreFailedRead = Util\Str::toBoolean(Util\Arr::getValue($conf, 'ignoreFailedRead', ''), false); |
121 | 123 | $this->removeSourceDir = Util\Str::toBoolean(Util\Arr::getValue($conf, 'removeSourceDir', ''), false); |
| 124 | + } |
122 | 125 |
|
123 | | - if (empty($this->path)) { |
| 126 | + /** |
| 127 | + * Setup the path to the directory that should be compressed. |
| 128 | + * |
| 129 | + * @param array $conf |
| 130 | + * @throws \phpbu\App\Exception |
| 131 | + */ |
| 132 | + protected function setupPath(array $conf) |
| 133 | + { |
| 134 | + $path = Util\Arr::getValue($conf, 'path', ''); |
| 135 | + if (empty($path)) { |
124 | 136 | throw new Exception('path option is mandatory'); |
125 | 137 | } |
| 138 | + $this->path = Util\Path::toAbsolutePath($path, Configuration::getWorkingDirectory()); |
| 139 | + if (!file_exists($this->path)) { |
| 140 | + throw new Exception('could not find directory to compress'); |
| 141 | + } |
126 | 142 | } |
127 | 143 |
|
128 | 144 | /** |
|
0 commit comments