diff --git a/bin/sourceDila.php b/bin/sourceDila.php index 47ca2291..3f911a4e 100644 --- a/bin/sourceDila.php +++ b/bin/sourceDila.php @@ -246,8 +246,13 @@ if ($opts->cron || $oneShot) { // --- Fichier déjà présent en base else { $fileRow = $fileStmt->fetch(\PDO::FETCH_OBJ); + $dateFile = new DateTime(); + $dateFile->createFromFormat($fileRow->dateInsert, 'YmdHis'); + $dateC = new DateTime(); + $dateC->sub(new DateInterval('P4D')); $sizeOnDisk = filesize($storageDir.'/'.$file); - if ($ftpSize < ($sizeOnDisk - 1000) || $ftpSize > ($sizeOnDisk + 1000)) { + if ($dateFile < $dateC + && ($ftpSize < ($sizeOnDisk - 2000) || $ftpSize > ($sizeOnDisk + 2000))) { rename($storageDir.'/'.$file, $storageDir.'/'.$file.'_'.date('YmdHis')); $downloadFile = true; } diff --git a/bin/sourceInsee.php b/bin/sourceInsee.php index 0c025ffb..4d9da7bd 100644 --- a/bin/sourceInsee.php +++ b/bin/sourceInsee.php @@ -26,6 +26,13 @@ if ($optionsNb == 0 || isset($opts->help)) { $displayUsage = true; } +// --- Usage +if ($displayUsage) { + echo "Recuperation des fichiers INSEE FTPs.\n"; + echo $opts->getUsageMessage(); + exit; +} + $BASEPATH = realpath(APPLICATION_PATH . '/../'); $STORAGEBASE = $c->profil->path->shared.'/sources/insee'; $FTP_URL = "ftp://81.255.68.110:21/download/"; diff --git a/composer.json b/composer.json index 600713a5..35d5a6eb 100644 --- a/composer.json +++ b/composer.json @@ -5,7 +5,9 @@ "zendframework/zendframework1": "^1.12", "doctrine/dbal": "^2.5", "league/csv": "^8.1", - "scores/library": "dev-master" + "scores/library": "dev-master", + "guzzlehttp/guzzle": "^6.2", + "monolog/monolog": "^1.22" }, "repositories": [ { diff --git a/composer.lock b/composer.lock index b7cbd9b0..f7519ba4 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "content-hash": "6ce90ad86283d1b9ac07edc9114ce33c", + "content-hash": "2af1e58294025796833c2197e0d2b51c", "packages": [ { "name": "doctrine/annotations", @@ -475,6 +475,184 @@ ], "time": "2014-09-09T13:34:57+00:00" }, + { + "name": "guzzlehttp/guzzle", + "version": "6.2.3", + "source": { + "type": "git", + "url": "https://github.com/guzzle/guzzle.git", + "reference": "8d6c6cc55186db87b7dc5009827429ba4e9dc006" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/guzzle/guzzle/zipball/8d6c6cc55186db87b7dc5009827429ba4e9dc006", + "reference": "8d6c6cc55186db87b7dc5009827429ba4e9dc006", + "shasum": "" + }, + "require": { + "guzzlehttp/promises": "^1.0", + "guzzlehttp/psr7": "^1.4", + "php": ">=5.5" + }, + "require-dev": { + "ext-curl": "*", + "phpunit/phpunit": "^4.0", + "psr/log": "^1.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "6.2-dev" + } + }, + "autoload": { + "files": [ + "src/functions_include.php" + ], + "psr-4": { + "GuzzleHttp\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Michael Dowling", + "email": "mtdowling@gmail.com", + "homepage": "https://github.com/mtdowling" + } + ], + "description": "Guzzle is a PHP HTTP client library", + "homepage": "http://guzzlephp.org/", + "keywords": [ + "client", + "curl", + "framework", + "http", + "http client", + "rest", + "web service" + ], + "time": "2017-02-28T22:50:30+00:00" + }, + { + "name": "guzzlehttp/promises", + "version": "v1.3.1", + "source": { + "type": "git", + "url": "https://github.com/guzzle/promises.git", + "reference": "a59da6cf61d80060647ff4d3eb2c03a2bc694646" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/guzzle/promises/zipball/a59da6cf61d80060647ff4d3eb2c03a2bc694646", + "reference": "a59da6cf61d80060647ff4d3eb2c03a2bc694646", + "shasum": "" + }, + "require": { + "php": ">=5.5.0" + }, + "require-dev": { + "phpunit/phpunit": "^4.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.4-dev" + } + }, + "autoload": { + "psr-4": { + "GuzzleHttp\\Promise\\": "src/" + }, + "files": [ + "src/functions_include.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Michael Dowling", + "email": "mtdowling@gmail.com", + "homepage": "https://github.com/mtdowling" + } + ], + "description": "Guzzle promises library", + "keywords": [ + "promise" + ], + "time": "2016-12-20T10:07:11+00:00" + }, + { + "name": "guzzlehttp/psr7", + "version": "1.4.2", + "source": { + "type": "git", + "url": "https://github.com/guzzle/psr7.git", + "reference": "f5b8a8512e2b58b0071a7280e39f14f72e05d87c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/guzzle/psr7/zipball/f5b8a8512e2b58b0071a7280e39f14f72e05d87c", + "reference": "f5b8a8512e2b58b0071a7280e39f14f72e05d87c", + "shasum": "" + }, + "require": { + "php": ">=5.4.0", + "psr/http-message": "~1.0" + }, + "provide": { + "psr/http-message-implementation": "1.0" + }, + "require-dev": { + "phpunit/phpunit": "~4.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.4-dev" + } + }, + "autoload": { + "psr-4": { + "GuzzleHttp\\Psr7\\": "src/" + }, + "files": [ + "src/functions_include.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Michael Dowling", + "email": "mtdowling@gmail.com", + "homepage": "https://github.com/mtdowling" + }, + { + "name": "Tobias Schultze", + "homepage": "https://github.com/Tobion" + } + ], + "description": "PSR-7 message implementation that also provides common utility methods", + "keywords": [ + "http", + "message", + "request", + "response", + "stream", + "uri", + "url" + ], + "time": "2017-03-20T17:10:46+00:00" + }, { "name": "league/csv", "version": "8.2.1", @@ -610,6 +788,56 @@ ], "time": "2017-03-13T07:08:03+00:00" }, + { + "name": "psr/http-message", + "version": "1.0.1", + "source": { + "type": "git", + "url": "https://github.com/php-fig/http-message.git", + "reference": "f6561bf28d520154e4b0ec72be95418abe6d9363" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/http-message/zipball/f6561bf28d520154e4b0ec72be95418abe6d9363", + "reference": "f6561bf28d520154e4b0ec72be95418abe6d9363", + "shasum": "" + }, + "require": { + "php": ">=5.3.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Http\\Message\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "http://www.php-fig.org/" + } + ], + "description": "Common interface for HTTP messages", + "homepage": "https://github.com/php-fig/http-message", + "keywords": [ + "http", + "http-message", + "psr", + "psr-7", + "request", + "response" + ], + "time": "2016-08-06T14:39:51+00:00" + }, { "name": "psr/log", "version": "1.0.2", @@ -663,7 +891,7 @@ "source": { "type": "git", "url": "git@gitlab.factory.insight.doubletrade.com:scores/library.git", - "reference": "9c2f4d110c1d182f3afefec341f6e93145c2c3de" + "reference": "8fb0710a36cbc1da91e271afc7b7f2d92c39574c" }, "require": { "doctrine/dbal": "^2.5", @@ -691,7 +919,7 @@ } ], "description": "library", - "time": "2017-04-03 09:19:15" + "time": "2017-04-05 12:44:24" }, { "name": "zendframework/zendframework1",