GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( 411cd6...1a4d39 )
by Liuta
02:55
created
includes/class-xcloner-logger.php 1 patch
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -4,32 +4,32 @@  discard block
 block discarded – undo
4 4
 use Monolog\Handler\StreamHandler;
5 5
 use Monolog\Handler\RotatingFileHandler;
6 6
 
7
-class Xcloner_Logger extends Logger{
7
+class Xcloner_Logger extends Logger {
8 8
 	
9
-	private $logger_path ;
9
+	private $logger_path;
10 10
 	private $max_logger_files = 15;
11 11
 	private $main_logger_url;
12 12
 	
13
-	public function __construct($logger_name = "xcloner_logger", $hash="")
13
+	public function __construct($logger_name = "xcloner_logger", $hash = "")
14 14
 	{
15
-		$xcloner_settings 	= new Xcloner_Settings($hash);
16
-		$logger_path 		= $xcloner_settings->get_xcloner_store_path().DS.$xcloner_settings->get_logger_filename();
15
+		$xcloner_settings = new Xcloner_Settings($hash);
16
+		$logger_path = $xcloner_settings->get_xcloner_store_path().DS.$xcloner_settings->get_logger_filename();
17 17
 		$logger_path_tmp 	= "";
18 18
 		
19
-		if($hash)
19
+		if ($hash)
20 20
 			$logger_path_tmp = $xcloner_settings->get_xcloner_tmp_path().DS.$xcloner_settings->get_logger_filename(1);
21 21
 		
22 22
 		
23 23
 		$this->logger_path = $logger_path;
24 24
 		//$this->logger_path_tmp = $logger_path_tmp;
25 25
 		
26
-		if(!is_dir($xcloner_settings->get_xcloner_store_path()) or !is_writable($xcloner_settings->get_xcloner_store_path()))
26
+		if (!is_dir($xcloner_settings->get_xcloner_store_path()) or !is_writable($xcloner_settings->get_xcloner_store_path()))
27 27
 		{
28 28
 			$logger_path = "php://stderr";
29 29
 			$logger_path_tmp = "";
30 30
 		}
31 31
 		
32
-		if(!$xcloner_settings->get_xcloner_option('xcloner_enable_log'))
32
+		if (!$xcloner_settings->get_xcloner_option('xcloner_enable_log'))
33 33
 		{
34 34
 			$logger_path = "php://stderr";
35 35
 			$logger_path_tmp = "";
@@ -40,19 +40,19 @@  discard block
 block discarded – undo
40 40
 		
41 41
 		$debug_level = Logger::INFO;
42 42
 		
43
-		if(WP_DEBUG)
43
+		if (WP_DEBUG)
44 44
 			$debug_level = Logger::DEBUG;
45 45
 
46 46
 	
47
-		if($logger_path)
47
+		if ($logger_path)
48 48
 		{
49 49
 			$stream = new RotatingFileHandler($logger_path, $this->max_logger_files, $debug_level);
50 50
 			$this->pushHandler($stream);
51 51
 			
52
-			$this->main_logger_url =  $stream->getUrl();
52
+			$this->main_logger_url = $stream->getUrl();
53 53
 		}
54 54
 			
55
-		if($hash and $logger_path_tmp)
55
+		if ($hash and $logger_path_tmp)
56 56
 			$this->pushHandler(new StreamHandler($logger_path_tmp, $debug_level));
57 57
 		
58 58
 		return $this;
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
 		$lines = array();
69 69
 		
70 70
 		//if(!file_exists($this->logger_path) or !is_readable($this->logger_path))
71
-		if(!file_exists($this->main_logger_url) or !is_readable($this->main_logger_url))
71
+		if (!file_exists($this->main_logger_url) or !is_readable($this->main_logger_url))
72 72
 			return false;
73 73
 		
74 74
 		//$fp = fopen($this->logger_path, 'r');
@@ -78,12 +78,12 @@  discard block
 block discarded – undo
78 78
 		$lastLine = "";
79 79
 		
80 80
 		// Loop backword until we have our lines or we reach the start
81
-		while($pos > 0 && count($lines) < $totalLines) {
81
+		while ($pos > 0 && count($lines) < $totalLines) {
82 82
 		
83 83
 		$C = fgetc($fp);
84
-		if($C == "\n") {
84
+		if ($C == "\n") {
85 85
 		  // skip empty lines
86
-		  if(trim($lastLine) != "") {
86
+		  if (trim($lastLine) != "") {
87 87
 			$lines[] = $lastLine;
88 88
 		  }
89 89
 		  $lastLine = '';
Please login to merge, or discard this patch.
includes/class-xcloner-archive.php 1 patch
Spacing   +79 added lines, -79 removed lines patch added patch discarded remove patch
@@ -8,9 +8,9 @@  discard block
 block discarded – undo
8 8
 	/*
9 9
 	 * bytes
10 10
 	 */ 
11
-	private $file_size_per_request_limit	= 52428800 ; //50MB = 52428800; 1MB = 1048576
12
-	private $files_to_process_per_request 	= 250; //block of 512 bytes
13
-	private $compression_level 				= 0; //0-9 , 0 uncompressed
11
+	private $file_size_per_request_limit	= 52428800; //50MB = 52428800; 1MB = 1048576
12
+	private $files_to_process_per_request = 250; //block of 512 bytes
13
+	private $compression_level = 0; //0-9 , 0 uncompressed
14 14
 	private $xcloner_split_backup_limit		= 2048; //2048MB
15 15
 	
16 16
 	private $archive_name;
@@ -18,25 +18,25 @@  discard block
 block discarded – undo
18 18
 	
19 19
 	public function __construct($hash = "", $archive_name = "")
20 20
 	{
21
-		$this->filesystem 		= new Xcloner_File_System($hash);
22
-		$this->logger 			= new XCloner_Logger('xcloner_archive', $hash);
21
+		$this->filesystem = new Xcloner_File_System($hash);
22
+		$this->logger = new XCloner_Logger('xcloner_archive', $hash);
23 23
 		$this->xcloner_settings = new Xcloner_Settings($hash);
24 24
 		
25
-		if($value = $this->xcloner_settings->get_xcloner_option('xcloner_size_limit_per_request'))
26
-			$this->file_size_per_request_limit = $value*1024*1024; //MB
25
+		if ($value = $this->xcloner_settings->get_xcloner_option('xcloner_size_limit_per_request'))
26
+			$this->file_size_per_request_limit = $value * 1024 * 1024; //MB
27 27
 			
28
-		if($value = $this->xcloner_settings->get_xcloner_option('xcloner_files_to_process_per_request'))
28
+		if ($value = $this->xcloner_settings->get_xcloner_option('xcloner_files_to_process_per_request'))
29 29
 			$this->files_to_process_per_request = $value;
30 30
 		
31
-		if($value = get_option('xcloner_backup_compression_level'))
31
+		if ($value = get_option('xcloner_backup_compression_level'))
32 32
 			$this->compression_level = $value;
33 33
 		
34
-		if($value = get_option('xcloner_split_backup_limit'))
34
+		if ($value = get_option('xcloner_split_backup_limit'))
35 35
 			$this->xcloner_split_backup_limit = $value;
36 36
 		
37
-		$this->xcloner_split_backup_limit = $this->xcloner_split_backup_limit * 1024*1024; //transform to bytes
37
+		$this->xcloner_split_backup_limit = $this->xcloner_split_backup_limit * 1024 * 1024; //transform to bytes
38 38
 			
39
-		if(isset($archive_name))
39
+		if (isset($archive_name))
40 40
 			$this->set_archive_name($archive_name);
41 41
 	}
42 42
 	
@@ -61,11 +61,11 @@  discard block
 block discarded – undo
61 61
 	{
62 62
 		$this->archive_name = $this->filesystem->process_backup_name($name);
63 63
 		
64
-		if(isset($part) and $part)
64
+		if (isset($part) and $part)
65 65
 		{
66
-			$new_name =  preg_replace('/-part(\d*)/', "-part".$part, $this->archive_name);
67
-			if(!stristr($new_name, "-part"))
68
-				$new_name = $this->archive_name . "-part".$part;
66
+			$new_name = preg_replace('/-part(\d*)/', "-part".$part, $this->archive_name);
67
+			if (!stristr($new_name, "-part"))
68
+				$new_name = $this->archive_name."-part".$part;
69 69
 			
70 70
 			$this->archive_name = $new_name;	
71 71
 		}
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
 	 */ 
91 91
 	public function get_archive_name_multipart()
92 92
 	{
93
-		$new_name =  preg_replace('/-part(\d*)/', "", $this->archive_name);
93
+		$new_name = preg_replace('/-part(\d*)/', "", $this->archive_name);
94 94
 		return $new_name."-multipart".$this->xcloner_settings->get_backup_extension_name(".csv");
95 95
 	}
96 96
 	
@@ -112,7 +112,7 @@  discard block
 block discarded – undo
112 112
 	public function send_notification_error($to, $from, $subject, $backup_name, $params, $error_message)
113 113
 	{
114 114
 		
115
-		$body  = $error_message; 
115
+		$body = $error_message; 
116 116
 		
117 117
 		$this->logger->info(sprintf("Sending backup error notification to %s", $to));
118 118
 		
@@ -120,10 +120,10 @@  discard block
 block discarded – undo
120 120
 		
121 121
 		$headers = array('Content-Type: text/html; charset=UTF-8');
122 122
 		
123
-		if($admin_email and $from )
123
+		if ($admin_email and $from)
124 124
 			$headers[] = 'From: '.$from.' <'.$admin_email.'>';
125 125
 
126
-		$return = wp_mail( $to, $subject, $body, $headers );
126
+		$return = wp_mail($to, $subject, $body, $headers);
127 127
 		
128 128
 		return $return;
129 129
 	}
@@ -133,47 +133,47 @@  discard block
 block discarded – undo
133 133
 	 * Send backup archive notfication by E-Mail
134 134
 	 * 
135 135
 	 */ 
136
-	public function send_notification($to, $from, $subject, $backup_name, $params, $error_message="")
136
+	public function send_notification($to, $from, $subject, $backup_name, $params, $error_message = "")
137 137
 	{
138
-		if(!$from)
138
+		if (!$from)
139 139
 			$from = "XCloner Backup";
140 140
 			
141
-		if(($error_message))
141
+		if (($error_message))
142 142
 		{
143 143
 			return $this->send_notification_error($to, $from, $subject, $backup_name, $params, $error_message);
144 144
 		}
145 145
 		
146 146
 		$params = (array)$params;
147 147
 		
148
-		if(!$subject)
149
-			$subject = sprintf(__("New backup generated %s") ,$backup_name);
148
+		if (!$subject)
149
+			$subject = sprintf(__("New backup generated %s"), $backup_name);
150 150
 			
151 151
 		$body = sprintf(__("Generated Backup Size: %s"), size_format($this->filesystem->get_backup_size($backup_name)));
152 152
 		$body .= "<br /><br />";
153 153
 		
154 154
 		$backup_parts = $this->filesystem->get_multipart_files($backup_name);
155 155
 		
156
-		if(!$backups_counter = sizeof($backup_parts))
156
+		if (!$backups_counter = sizeof($backup_parts))
157 157
 			$backups_counter = 1;
158 158
 		
159 159
 		$body .= sprintf(__("Backup Parts: %s"), $backups_counter);
160 160
 		$body .= "<br />";
161 161
 		
162
-		if(sizeof($backup_parts))
162
+		if (sizeof($backup_parts))
163 163
 		{
164
-			$body .= implode("<br />",$backup_parts);
164
+			$body .= implode("<br />", $backup_parts);
165 165
 			$body .= "<br />";
166 166
 		}
167 167
 		
168
-		$body.= "<br />";
168
+		$body .= "<br />";
169 169
 		
170
-		if(isset($params['backup_params']->backup_comments))
170
+		if (isset($params['backup_params']->backup_comments))
171 171
 		{
172 172
 			$body .= __("Backup Comments: ").$params['backup_params']->backup_comments;
173 173
 			$body .= "<br /><br />";
174 174
 		}
175 175
 		
176
-		if($this->xcloner_settings->get_xcloner_option('xcloner_enable_log'))
176
+		if ($this->xcloner_settings->get_xcloner_option('xcloner_enable_log'))
177 177
 			$body .= __("Latest 50 Log Lines: ")."<br />".implode("<br />\n", $this->logger->getLastDebugLines(50));
178 178
 		
179 179
 		$attachments = $this->filesystem->get_backup_attachments();
@@ -183,7 +183,7 @@  discard block
 block discarded – undo
183 183
 		$tar = new Tar();
184 184
 		$tar->create($attachments_archive);
185 185
 			
186
-		foreach($attachments as $key => $file)
186
+		foreach ($attachments as $key => $file)
187 187
 		{
188 188
 			$tar->addFile($file, basename($file));
189 189
 		}
@@ -195,7 +195,7 @@  discard block
 block discarded – undo
195 195
 		
196 196
 		$headers = array('Content-Type: text/html; charset=UTF-8', 'From: '.$from.' <'.$admin_email.'>');
197 197
 		
198
-		$return = wp_mail( $to, $subject, $body, $headers, array($attachments_archive) );
198
+		$return = wp_mail($to, $subject, $body, $headers, array($attachments_archive));
199 199
 	
200 200
 		return $return;
201 201
 	}
@@ -209,17 +209,17 @@  discard block
 block discarded – undo
209 209
 	{
210 210
 		$return = array();
211 211
 		
212
-		if(!isset($extra_params['backup_part']))
212
+		if (!isset($extra_params['backup_part']))
213 213
 			$extra_params['backup_part'] = 0;
214 214
 		
215 215
 		$return['extra']['backup_part'] = $extra_params['backup_part'];
216 216
 					
217
-		if(isset( $extra_params['backup_archive_name']))
217
+		if (isset($extra_params['backup_archive_name']))
218 218
 			$this->set_archive_name($extra_params['backup_archive_name'], $return['extra']['backup_part']);
219 219
 		else
220 220
 			$this->set_archive_name($backup_params['backup_name']);
221 221
 			
222
-		if(!$this->get_archive_name())
222
+		if (!$this->get_archive_name())
223 223
 			$this->set_archive_name();
224 224
 		
225 225
 		$this->backup_archive = new Tar();
@@ -227,7 +227,7 @@  discard block
 block discarded – undo
227 227
 		
228 228
 		$archive_info = $this->filesystem->get_storage_path_file_info($this->get_archive_name_with_extension());
229 229
 		
230
-		if($init)
230
+		if ($init)
231 231
 		{
232 232
 			$this->logger->info(sprintf(__("Initializing the backup archive %s"), $this->get_archive_name()));
233 233
 		
@@ -235,7 +235,7 @@  discard block
 block discarded – undo
235 235
 			
236 236
 			$return['extra']['backup_init'] = 1;
237 237
 			
238
-		}else{
238
+		} else {
239 239
 			$this->logger->info(sprintf(__("Opening for append the backup archive %s"), $this->get_archive_name()));
240 240
 			
241 241
 			$this->backup_archive->openForAppend($archive_info->getPath().DS.$archive_info->getFilename());
@@ -247,13 +247,13 @@  discard block
 block discarded – undo
247 247
 		$return['extra']['backup_archive_name'] = $this->get_archive_name();
248 248
 		$return['extra']['backup_archive_name_full'] = $this->get_archive_name_with_extension();
249 249
 		
250
-		if(!isset($extra_params['start_at_line']))
250
+		if (!isset($extra_params['start_at_line']))
251 251
 			$extra_params['start_at_line'] = 0;
252 252
 		
253
-		if(!isset($extra_params['start_at_byte']))
253
+		if (!isset($extra_params['start_at_byte']))
254 254
 			$extra_params['start_at_byte'] = 0;
255 255
 		
256
-		if(!$this->filesystem->get_tmp_filesystem()->has($this->filesystem->get_included_files_handler()))
256
+		if (!$this->filesystem->get_tmp_filesystem()->has($this->filesystem->get_included_files_handler()))
257 257
 		{
258 258
 			$this->logger->error(sprintf("Missing the includes file handler %s, aborting...", $this->filesystem->get_included_files_handler()));
259 259
 			
@@ -279,7 +279,7 @@  discard block
 block discarded – undo
279 279
 		
280 280
 		$byte_limit = 0;
281 281
 		
282
-		while(!$file->eof() and $counter<=$this->files_to_process_per_request)
282
+		while (!$file->eof() and $counter <= $this->files_to_process_per_request)
283 283
 		{
284 284
 			$line = str_getcsv($file->current());
285 285
 
@@ -287,13 +287,13 @@  discard block
 block discarded – undo
287 287
 			
288 288
 			$start_filesystem = "start_filesystem";
289 289
 			
290
-			if(isset($line[4])){
290
+			if (isset($line[4])) {
291 291
 				$start_filesystem = $line[4];
292 292
 			}
293 293
 			
294 294
 			//$adapter = $this->filesystem->get_adapter($start_filesystem);
295 295
 			
296
-			if(!$this->filesystem->get_filesystem($start_filesystem)->has($relative_path))
296
+			if (!$this->filesystem->get_filesystem($start_filesystem)->has($relative_path))
297 297
 			{
298 298
 				$extra_params['start_at_line']++;
299 299
 				$file->next();
@@ -302,35 +302,35 @@  discard block
 block discarded – undo
302 302
 			
303 303
 			$file_info = $this->filesystem->get_filesystem($start_filesystem)->getMetadata($relative_path);
304 304
 			
305
-			if(!isset($file_info['size']))
305
+			if (!isset($file_info['size']))
306 306
 				$file_info['size'] = 0;
307 307
 			
308
-			if($start_filesystem == "tmp_filesystem")	
308
+			if ($start_filesystem == "tmp_filesystem")	
309 309
 				$file_info['archive_prefix_path'] = $this->xcloner_settings->get_xcloner_tmp_path_suffix();
310 310
 			
311
-			$byte_limit = (int)$this->file_size_per_request_limit/512;
311
+			$byte_limit = (int)$this->file_size_per_request_limit / 512;
312 312
 			
313 313
 			$append = 0;
314 314
 			
315
-			if($file_info['size'] > $byte_limit*512 or $start_byte)
315
+			if ($file_info['size'] > $byte_limit * 512 or $start_byte)
316 316
 				$append = 1;
317 317
 						
318
-			if(!isset($return['extra']['backup_size']))
319
-				$return['extra']['backup_size'] =0;
318
+			if (!isset($return['extra']['backup_size']))
319
+				$return['extra']['backup_size'] = 0;
320 320
 			
321 321
 			$return['extra']['backup_size'] = $archive_info->getSize();
322 322
 			
323 323
 			$estimated_new_size = $return['extra']['backup_size'] + $file_info['size'];
324 324
 			
325 325
 			//we create a new backup part if we reach the Split Achive Limit
326
-			if($this->xcloner_split_backup_limit and ($estimated_new_size > $this->xcloner_split_backup_limit) and (!$start_byte))
326
+			if ($this->xcloner_split_backup_limit and ($estimated_new_size > $this->xcloner_split_backup_limit) and (!$start_byte))
327 327
 			{
328
-				$this->logger->info(sprintf("Backup size limit %s bytes reached, file add estimate %s, attempt to create a new archive ",$this->xcloner_split_backup_limit, $estimated_new_size));
328
+				$this->logger->info(sprintf("Backup size limit %s bytes reached, file add estimate %s, attempt to create a new archive ", $this->xcloner_split_backup_limit, $estimated_new_size));
329 329
 				list($archive_info, $return['extra']['backup_part']) = $this->create_new_backup_part($return['extra']['backup_part']);
330 330
 				
331
-				if($file_info['size'] > $this->xcloner_split_backup_limit)
331
+				if ($file_info['size'] > $this->xcloner_split_backup_limit)
332 332
 				{
333
-					$this->logger->info(sprintf("Excluding %s file as it's size(%s) is bigger than the backup split limit of %s and it won't fit a single backup file",$file_info['path'], $file_info['size'], $this->xcloner_split_backup_limit));
333
+					$this->logger->info(sprintf("Excluding %s file as it's size(%s) is bigger than the backup split limit of %s and it won't fit a single backup file", $file_info['path'], $file_info['size'], $this->xcloner_split_backup_limit));
334 334
 					$extra_params['start_at_line']++;
335 335
 				}
336 336
 				
@@ -342,7 +342,7 @@  discard block
 block discarded – undo
342 342
 				return $return;
343 343
 			}
344 344
 			
345
-			list($bytes_wrote, $last_position) = $this->add_file_to_archive( $file_info, $start_byte, $byte_limit, $append, $start_filesystem);
345
+			list($bytes_wrote, $last_position) = $this->add_file_to_archive($file_info, $start_byte, $byte_limit, $append, $start_filesystem);
346 346
 			$this->processed_size_bytes += $bytes_wrote;
347 347
 			
348 348
 			//echo" - processed ".$this->processed_size_bytes." bytes ".$this->file_size_per_request_limit." last_position:".$last_position." \n";
@@ -350,17 +350,17 @@  discard block
 block discarded – undo
350 350
 			$return['extra']['processed_file_size'] = $file_info['size'];
351 351
 			$return['extra']['backup_size'] = $archive_info->getSize();
352 352
 			
353
-			if($last_position>0){	
353
+			if ($last_position > 0) {	
354 354
 				$start_byte = $last_position;
355 355
 			}
356
-			else{	
356
+			else {	
357 357
 				$extra_params['start_at_line']++;
358 358
 				$file->next();
359 359
 				$start_byte = 0;
360 360
 				$counter++;
361 361
 			}
362 362
 			
363
-			if($this->processed_size_bytes >= $this->file_size_per_request_limit)
363
+			if ($this->processed_size_bytes >= $this->file_size_per_request_limit)
364 364
 			{
365 365
 				clearstatcache();
366 366
 				$return['extra']['backup_size'] = $archive_info->getSize();
@@ -373,7 +373,7 @@  discard block
 block discarded – undo
373 373
 			}
374 374
 		}
375 375
 		
376
-		if(!$file->eof())
376
+		if (!$file->eof())
377 377
 		{
378 378
 			clearstatcache();
379 379
 			$return['extra']['backup_size'] = $archive_info->getSize();
@@ -390,12 +390,12 @@  discard block
 block discarded – undo
390 390
 		$this->logger->info(sprintf("Closing the backup archive %s with 2*512 zero bytes blocks.", $this->get_archive_name_with_extension()));
391 391
 		$this->backup_archive->close();
392 392
 				
393
-		if($return['extra']['backup_part'])
393
+		if ($return['extra']['backup_part'])
394 394
 			$this->write_multipart_file($this->get_archive_name_with_extension());
395 395
 		
396
-		$return['extra']['start_at_line'] = $extra_params['start_at_line']-1;
396
+		$return['extra']['start_at_line'] = $extra_params['start_at_line'] - 1;
397 397
 		
398
-		if(isset($file_info))
398
+		if (isset($file_info))
399 399
 		{
400 400
 			$return['extra']['processed_file'] = $file_info['path'];
401 401
 			$return['extra']['processed_file_size'] = $file_info['size'];
@@ -437,20 +437,20 @@  discard block
 block discarded – undo
437 437
 		$this->logger->info(sprintf("Closing the backup archive %s with 2*512 zero bytes blocks.", $this->get_archive_name_with_extension()));
438 438
 		$this->backup_archive->close();		
439 439
 		
440
-		if(!$part)
440
+		if (!$part)
441 441
 		{
442 442
 			$old_name = $this->get_archive_name_with_extension();
443 443
 			$this->set_archive_name($this->get_archive_name(), ++$part);
444 444
 			$this->rename_archive($old_name, $this->get_archive_name_with_extension());
445 445
 			
446
-			if($this->filesystem->get_storage_filesystem()->has($this->get_archive_name_multipart()))
446
+			if ($this->filesystem->get_storage_filesystem()->has($this->get_archive_name_multipart()))
447 447
 				$this->filesystem->get_storage_filesystem()->delete($this->get_archive_name_multipart());
448 448
 				
449 449
 			$this->write_multipart_file($this->get_archive_name_with_extension());
450 450
 			
451
-		}else
451
+		} else
452 452
 		{
453
-			$this->logger->info(sprintf("Creating new multipart info file %s",$this->get_archive_name_with_extension()));
453
+			$this->logger->info(sprintf("Creating new multipart info file %s", $this->get_archive_name_with_extension()));
454 454
 			$this->write_multipart_file($this->get_archive_name_with_extension());
455 455
 		}
456 456
 				
@@ -478,10 +478,10 @@  discard block
 block discarded – undo
478 478
 		$start_adapter = $this->filesystem->get_adapter($filesystem);
479 479
 		$start_filesystem = $this->filesystem->get_adapter($filesystem);
480 480
 		
481
-		if(!$file_info['path'])
481
+		if (!$file_info['path'])
482 482
 			return;
483 483
 		
484
-		if(isset($file_info['archive_prefix_path']))	
484
+		if (isset($file_info['archive_prefix_path']))	
485 485
 			$file_info['target_path'] = $file_info['archive_prefix_path']."/".$file_info['path'];
486 486
 		else
487 487
 			$file_info['target_path'] = $file_info['path'];
@@ -490,36 +490,36 @@  discard block
 block discarded – undo
490 490
 		
491 491
 		//$start_adapter = $this->filesystem->get_start_adapter();
492 492
 
493
-		if(!$append){
493
+		if (!$append) {
494 494
 			$bytes_wrote = $file_info['size'];
495 495
 			$this->logger->info(sprintf("Adding %s bytes of file %s to archive %s ", $bytes_wrote, $file_info['target_path'], $this->get_archive_name_with_extension()));
496 496
 			$this->backup_archive->addFile($start_adapter->applyPathPrefix($file_info['path']), $file_info['target_path']);
497 497
 		}
498
-		else{	
498
+		else {	
499 499
 			$tmp_file = md5($file_info['path']);
500 500
 			
501 501
 			//we isolate file to tmp if we are at byte 0, the starting point of file reading
502
-			if(!$start_at_byte)
502
+			if (!$start_at_byte)
503 503
 			{
504 504
 				$this->logger->info(sprintf("Copying %s file to tmp filesystem file %s to prevent reading changes", $file_info['path'], $tmp_file));
505 505
 				$file_stream = $start_filesystem->readStream($file_info['path']);
506 506
 				
507
-				if(is_resource($file_stream['stream']))
507
+				if (is_resource($file_stream['stream']))
508 508
 					$this->filesystem->get_tmp_filesystem()->writeStream($tmp_file, $file_stream['stream']);
509 509
 			}
510 510
 			
511
-			if($this->filesystem->get_tmp_filesystem()->has($tmp_file))
511
+			if ($this->filesystem->get_tmp_filesystem()->has($tmp_file))
512 512
 			{
513 513
 				$is_tmp = 1;
514 514
 				$last_position = $this->backup_archive->appendFileData($this->filesystem->get_tmp_filesystem_adapter()->applyPathPrefix($tmp_file), $file_info['target_path'], $start_at_byte, $byte_limit);
515 515
 			}
516
-			else{
516
+			else {
517 517
 				$is_tmp = 0;
518 518
 				$last_position = $this->backup_archive->appendFileData($start_adapter->applyPathPrefix($file_info['path']), $file_info['target_path'], $start_at_byte, $byte_limit);
519 519
 			}
520 520
 				
521 521
 			
522
-			if($last_position == -1)
522
+			if ($last_position == -1)
523 523
 			{
524 524
 				$bytes_wrote = $file_info['size'] - $start_at_byte;
525 525
 			}
@@ -529,18 +529,18 @@  discard block
 block discarded – undo
529 529
 			}
530 530
 			
531 531
 			
532
-			if($is_tmp)
532
+			if ($is_tmp)
533 533
 			{
534 534
 				$this->logger->info(sprintf("Appended %s bytes, starting position %s, of tmp file %s (%s) to archive %s ", $bytes_wrote, $start_at_byte, $tmp_file, $file_info['target_path'], $this->get_archive_name()));
535 535
 			}
536
-			else{
536
+			else {
537 537
 				$this->logger->info(sprintf("Appended %s bytes, starting position %s, of original file %s to archive %s ", $bytes_wrote, $start_at_byte, $file_info['target_path'], $tmp_file, $this->get_archive_name()));
538 538
 			}
539 539
 			
540 540
 			//we delete here the isolated tmp file
541
-			if($last_position == -1)
541
+			if ($last_position == -1)
542 542
 			{
543
-				if($this->filesystem->get_tmp_filesystem_adapter()->has($tmp_file))
543
+				if ($this->filesystem->get_tmp_filesystem_adapter()->has($tmp_file))
544 544
 				{
545 545
 					$this->logger->info(sprintf("Deleting %s from the tmp filesystem", $tmp_file));
546 546
 					$this->filesystem->get_tmp_filesystem_adapter()->delete($tmp_file);
Please login to merge, or discard this patch.