Skip to content

Commit

Permalink
Merge pull request #2 from phelipp/patch-1
Browse files Browse the repository at this point in the history
Update carddav2fb.php to retry a connection in case on a first try the connection didn't work.
  • Loading branch information
jens-maus committed Mar 13, 2015
2 parents 4747688 + 6c09700 commit 45b8031
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion carddav2fb.php
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,17 @@ public function get_carddav_entries() {
echo PHP_EOL.$message_successful."Successful upload of photo: ".$file;
unlink($file);
} else {
echo PHP_EOL.$message_error."While uploading file ".$file." an error occurred.".PHP_EOL;
// retry when a fault occurs.
echo PHP_EOL.$message_error."While uploading file ".$file." an error occurred. - retrying".PHP_EOL;
$conn_id = ftp_ssl_connect($ftp_server);
$login_result = ftp_login($conn_id, $this->config['fritzbox_user'], $this->config['fritzbox_pw']);
ftp_pasv($conn_id, true);
if (ftp_put($conn_id, $remote_path."/".$file, $remote_file, FTP_BINARY)) {
echo PHP_EOL.$message_successful."Successful upload of photo: ".$file;
unlink($file);
} else {
echo PHP_EOL.$message_error."While uploading file ".$file." an error occurred. - giving up".PHP_EOL;
}
}
}

Expand Down

0 comments on commit 45b8031

Please sign in to comment.