From 24fb6b9815b80d99f00a7a10e74227694ba5eed2 Mon Sep 17 00:00:00 2001 From: "Timothy J. Warren" Date: Fri, 26 Jun 2015 15:32:49 -0400 Subject: [PATCH] Add scrutinizer checks, and attempt to create cache folders if they do not exist --- .travis.yml | 10 +++++++++- app/models/AnimeModel.php | 8 +++++--- app/models/MangaModel.php | 6 ++++++ 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 52558996..91e40f39 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,4 +9,12 @@ php: - 5.6 - 7 - hhvm - - nightly \ No newline at end of file + - nightly + +script: + - mkdir -p build/logs + - phpunit --coverage-clover=coverage.clover + +after_script: + - wget https://scrutinizer-ci.com/ocular.phar + - php ocular.phar code-coverage:upload --format=php-clover coverage.clover \ No newline at end of file diff --git a/app/models/AnimeModel.php b/app/models/AnimeModel.php index af0221d7..0d841933 100644 --- a/app/models/AnimeModel.php +++ b/app/models/AnimeModel.php @@ -174,9 +174,6 @@ class AnimeModel extends BaseApiModel { $cache_file = "{$this->config->data_cache_path}/anime-{$status}.json"; $config = [ - /*'query' => [ - 'username' => $this->config->hummingbird_username, - ],*/ 'allow_redirects' => false ]; @@ -207,6 +204,11 @@ class AnimeModel extends BaseApiModel { if (( ! file_exists($cache_file)) || file_get_contents($cache_file) !== $output_json) { + // Attempt to create the cache folder if it doesn't exist + if ( ! is_dir($this->config->data_cache_path)) + { + mkdir($this->config->data_cache_path); + } // Cache the call in case of downtime file_put_contents($cache_file, json_encode($output)); } diff --git a/app/models/MangaModel.php b/app/models/MangaModel.php index 1c7da0ce..4bbf0078 100644 --- a/app/models/MangaModel.php +++ b/app/models/MangaModel.php @@ -111,6 +111,12 @@ class MangaModel extends BaseApiModel { // Reorganize data to be more usable $raw_data = $response->json(); + // Attempt to create the cache dir if it doesn't exist + if ( ! is_dir($config->data_cache_path)) + { + mkdir($config->data_cache_path); + } + // Cache data in case of downtime file_put_contents($cache_file, json_encode($raw_data)); }