Skip to content

Commit

Permalink
Added a couple of checks in the update command to make sure the local…
Browse files Browse the repository at this point in the history
… storage directory exists and is writable.
  • Loading branch information
michaeldrennen committed May 29, 2019
1 parent 7d840ba commit 1caf30d
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/Console/UpdateGeonames.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 1caf30d

Please sign in to comment.