From 6c09700ca5bdec1a8428abae5282996b43bab705 Mon Sep 17 00:00:00 2001 From: phelipp Date: Sat, 20 Dec 2014 01:23:26 +0100 Subject: [PATCH] Update carddav2fb.php On slow computer or large address books a timeout can occur between opening the ftp connection and ftp activity. this reopens the connection on error. --- carddav2fb.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/carddav2fb.php b/carddav2fb.php index f2bcb952..e4ac0c8c 100644 --- a/carddav2fb.php +++ b/carddav2fb.php @@ -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; + } } }