From 1caf30daedfece12f8b85467b4697f1e9a6e27b2 Mon Sep 17 00:00:00 2001 From: Michael Drennen Date: Wed, 29 May 2019 07:07:21 -0600 Subject: [PATCH] Added a couple of checks in the update command to make sure the local storage directory exists and is writable. --- src/Console/UpdateGeonames.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/Console/UpdateGeonames.php b/src/Console/UpdateGeonames.php index c8fa3a1..a1d27c3 100644 --- a/src/Console/UpdateGeonames.php +++ b/src/Console/UpdateGeonames.php @@ -310,6 +310,16 @@ protected function saveRemoteModificationsFile() { // Save it locally $localFilePath = GeoSetting::getAbsoluteLocalStoragePath( $this->connectionName ) . DIRECTORY_SEPARATOR . $this->modificationsTxtFileName; + + // Determine if the local storage path exists and is writable. + if ( FALSE === file_exists( $localFilePath ) ): + throw new \Exception( "You need to create a directory at: " . $localFilePath ); + endif; + + if ( FALSE === is_writable( $localFilePath ) ): + throw new \Exception( "This directory needs to be writable: " . $localFilePath ); + endif; + $bytesWritten = file_put_contents( $localFilePath, $data ); if ( $bytesWritten === FALSE ) { Log::error( $absoluteUrlToModificationsFile,