diff options
-rw-r--r-- | Auth/OpenID/FileStore.php | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/Auth/OpenID/FileStore.php b/Auth/OpenID/FileStore.php index 2d49b77..0cc682d 100644 --- a/Auth/OpenID/FileStore.php +++ b/Auth/OpenID/FileStore.php @@ -164,17 +164,20 @@ class Auth_OpenID_FileStore extends Auth_OpenID_OpenIDStore { fflush($file_obj); fclose($file_obj); - if (!link($tmp, $this->auth_key_name)) { + if (function_exists('link')) { + // Posix filesystem + $saved = link($tmp, $this->auth_key_name); + Auth_OpenID_FileStore::_removeIfPresent($tmp); + } else { + // Windows filesystem + $saved = rename($tmp, $this->auth_key_name); + } + + if (!$saved) { // The link failed, either because we lack the permission, // or because the file already exists; try to read the key // in case the file already existed. $auth_key = $this->readAuthKey(); - - if (!$auth_key) { - return null; - } else { - Auth_OpenID_FileStore::_removeIfPresent($tmp); - } } return $auth_key; |