From 3e2d4c1bc1cb7c9d8e93848cfdc23491fd4e85f7 Mon Sep 17 00:00:00 2001 From: hkjolhede Date: Fri, 15 Nov 2013 21:10:09 +0100 Subject: [PATCH] Fixed error-checking error in sftp.php --- apps/files_external/lib/sftp.php | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/apps/files_external/lib/sftp.php b/apps/files_external/lib/sftp.php index fb1ecd5463..7c5aed5aa0 100644 --- a/apps/files_external/lib/sftp.php +++ b/apps/files_external/lib/sftp.php @@ -94,15 +94,17 @@ class SFTP extends \OC\Files\Storage\Common { private function writeHostKeys($keys) { try { $keyPath = $this->hostKeysPath(); - $fp = fopen($keyPath, 'w'); - foreach ($keys as $host => $key) { - fwrite($fp, $host . '::' . $key . "\n"); + if ($keyPath && file_exists($keyPath)) { + $fp = fopen($keyPath, 'w'); + foreach ($keys as $host => $key) { + fwrite($fp, $host . '::' . $key . "\n"); + } + fclose($fp); + return true; } - fclose($fp); - return true; } catch (\Exception $e) { - return false; } + return false; } private function readHostKeys() {