File tree Expand file tree Collapse file tree 3 files changed +22
-32
lines changed
Expand file tree Collapse file tree 3 files changed +22
-32
lines changed Original file line number Diff line number Diff line change 33
44use phpbu \App \Backup \Cli ;
55use phpbu \App \Backup \Target ;
6- use phpbu \App \Cli \Executable \Compressor ;
76use phpbu \App \Exception ;
87use phpbu \App \Result ;
98
@@ -53,6 +52,27 @@ public function __construct($path, $pathToCommand = null)
5352 $ this ->pathToCommand = $ pathToCommand ;
5453 }
5554
55+ /**
56+ * Compress the configured directory.
57+ *
58+ * @param \phpbu\App\Backup\Target $target
59+ * @param \phpbu\App\Result $result
60+ * @throws \phpbu\App\Exception
61+ */
62+ public function compress (Target $ target , Result $ result )
63+ {
64+ if (!$ target ->shouldBeCompressed ()) {
65+ throw new Exception ('target should not be compressed ' );
66+ }
67+
68+ $ res = $ this ->execute ($ target );
69+ $ result ->debug ($ res ->getCmd ());
70+
71+ if (0 !== $ res ->getCode ()) {
72+ throw new Exception ('Failed to \'compress \' file: ' . $ this ->path );
73+ }
74+ }
75+
5676 /**
5777 * Validate path.
5878 *
Original file line number Diff line number Diff line change @@ -39,17 +39,8 @@ public function isPathValid($path)
3939 */
4040 public function compress (Target $ target , Result $ result )
4141 {
42- if (!$ target ->shouldBeCompressed ()) {
43- throw new Exception ('target should not be compressed ' );
44- }
4542 $ target ->setMimeType ('application/x-tar ' );
46-
47- $ res = $ this ->execute ($ target );
48- $ result ->debug ($ res ->getCmd ());
49-
50- if (0 !== $ res ->getCode ()) {
51- throw new Exception ('Failed to \'tar \' directory: ' . $ this ->path );
52- }
43+ parent ::compress ($ target , $ result );
5344 }
5445
5546 /**
Original file line number Diff line number Diff line change @@ -31,27 +31,6 @@ public function isPathValid($path)
3131 return is_file ($ path );
3232 }
3333
34- /**
35- * Compress the configured directory.
36- *
37- * @param \phpbu\App\Backup\Target $target
38- * @param \phpbu\App\Result $result
39- * @throws \phpbu\App\Exception
40- */
41- public function compress (Target $ target , Result $ result )
42- {
43- if (!$ target ->shouldBeCompressed ()) {
44- throw new Exception ('target should not be compressed ' );
45- }
46-
47- $ res = $ this ->execute ($ target );
48- $ result ->debug ($ res ->getCmd ());
49-
50- if (0 !== $ res ->getCode ()) {
51- throw new Exception ('Failed to ' . $ target ->getCompressor ()->getCommand () . ' \'compress \' file: ' . $ this ->path );
52- }
53- }
54-
5534 /**
5635 * Returns the executable for this action.
5736 *
You can’t perform that action at this time.
0 commit comments