Commit fc5935328326469a957c5d70bdd6c4db8233e7af
1 parent
cdd2c7b6
Ntr
Showing
2 changed files
with
13 additions
and
16 deletions
Show diff stats
common/modules/product/models/Import.php
@@ -60,6 +60,11 @@ class Import extends Model { | @@ -60,6 +60,11 @@ class Import extends Model { | ||
60 | public function goPrices($from = 0, $limit = null) { | 60 | public function goPrices($from = 0, $limit = null) { |
61 | set_time_limit(0); | 61 | set_time_limit(0); |
62 | $new_products = $linked_products = 0; | 62 | $new_products = $linked_products = 0; |
63 | + if (file_exists(Yii::getAlias('@uploadDir/goPrices.lock'))) { | ||
64 | + return 'Task already executed'; | ||
65 | + } | ||
66 | + $ff = fopen(Yii::getAlias('@uploadDir/goPrices.lock'), 'w+'); | ||
67 | + fclose($ff); | ||
63 | 68 | ||
64 | if ( !($handle = $this->getProductsFile('uploadFilePrices')) ) { | 69 | if ( !($handle = $this->getProductsFile('uploadFilePrices')) ) { |
65 | $this->errors[] = 'File not found'; | 70 | $this->errors[] = 'File not found'; |
@@ -208,7 +213,7 @@ class Import extends Model { | @@ -208,7 +213,7 @@ class Import extends Model { | ||
208 | if ($result['end']) { | 213 | if ($result['end']) { |
209 | unlink(Yii::getAlias('@uploadDir') .'/'. Yii::getAlias('@uploadFilePrices')); | 214 | unlink(Yii::getAlias('@uploadDir') .'/'. Yii::getAlias('@uploadFilePrices')); |
210 | } | 215 | } |
211 | - | 216 | + unlink(Yii::getAlias('@uploadDir/goPrices.lock')); |
212 | return $result; | 217 | return $result; |
213 | } | 218 | } |
214 | 219 | ||
@@ -216,6 +221,11 @@ class Import extends Model { | @@ -216,6 +221,11 @@ class Import extends Model { | ||
216 | 221 | ||
217 | set_time_limit(0); | 222 | set_time_limit(0); |
218 | $new_products = $linked_products = 0; | 223 | $new_products = $linked_products = 0; |
224 | + if (file_exists(Yii::getAlias('@uploadDir/goProducts.lock'))) { | ||
225 | + return 'Task already executed'; | ||
226 | + } | ||
227 | + $ff = fopen(Yii::getAlias('@uploadDir/goProducts.lock'), 'w+'); | ||
228 | + fclose($ff); | ||
219 | 229 | ||
220 | if ( !($handle = $this->getProductsFile('uploadFileProducts')) ) { | 230 | if ( !($handle = $this->getProductsFile('uploadFileProducts')) ) { |
221 | $this->errors[] = 'File not found'; | 231 | $this->errors[] = 'File not found'; |
@@ -506,7 +516,7 @@ class Import extends Model { | @@ -506,7 +516,7 @@ class Import extends Model { | ||
506 | if ($result['end']) { | 516 | if ($result['end']) { |
507 | unlink(Yii::getAlias('@uploadDir') .'/'. Yii::getAlias('@uploadFileProducts')); | 517 | unlink(Yii::getAlias('@uploadDir') .'/'. Yii::getAlias('@uploadFileProducts')); |
508 | } | 518 | } |
509 | - | 519 | + unlink(Yii::getAlias('@uploadDir/goProducts.lock')); |
510 | return $result; | 520 | return $result; |
511 | } | 521 | } |
512 | 522 |
console/controllers/ImportController.php
@@ -50,28 +50,15 @@ class ImportController extends Controller { | @@ -50,28 +50,15 @@ class ImportController extends Controller { | ||
50 | } | 50 | } |
51 | 51 | ||
52 | public function actionProducts() { | 52 | public function actionProducts() { |
53 | - if (file_exists(Yii::getAlias('@uploadDir/goProducts.lock'))) { | ||
54 | - $this->errors[] = 'Task already executed'; | ||
55 | - return Controller::EXIT_CODE_ERROR; | ||
56 | - } | ||
57 | - $ff = fopen(Yii::getAlias('@uploadDir/goProducts.lock'), 'w+'); | ||
58 | - fclose($ff); | ||
59 | $model = new Import(); | 53 | $model = new Import(); |
60 | $model->goProducts(0, null); | 54 | $model->goProducts(0, null); |
61 | - unlink(Yii::getAlias('@uploadDir/goProducts.lock')); | ||
62 | return Controller::EXIT_CODE_NORMAL; | 55 | return Controller::EXIT_CODE_NORMAL; |
63 | } | 56 | } |
64 | 57 | ||
65 | public function actionPrices() { | 58 | public function actionPrices() { |
66 | - if (file_exists(Yii::getAlias('@uploadDir/goPrices.lock'))) { | ||
67 | - $this->stderr('Task already executed'); | ||
68 | - return Controller::EXIT_CODE_ERROR; | ||
69 | - } | ||
70 | - $ff = fopen(Yii::getAlias('@uploadDir/goPrices.lock'), 'w+'); | ||
71 | - fclose($ff); | 59 | + |
72 | $model = new Import(); | 60 | $model = new Import(); |
73 | $data = $model->goPrices(0, null); | 61 | $data = $model->goPrices(0, null); |
74 | - unlink(Yii::getAlias('@uploadDir/goPrices.lock')); | ||
75 | return Controller::EXIT_CODE_NORMAL; | 62 | return Controller::EXIT_CODE_NORMAL; |
76 | } | 63 | } |
77 | 64 |