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 | 60 | public function goPrices($from = 0, $limit = null) { |
61 | 61 | set_time_limit(0); |
62 | 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 | 69 | if ( !($handle = $this->getProductsFile('uploadFilePrices')) ) { |
65 | 70 | $this->errors[] = 'File not found'; |
... | ... | @@ -208,7 +213,7 @@ class Import extends Model { |
208 | 213 | if ($result['end']) { |
209 | 214 | unlink(Yii::getAlias('@uploadDir') .'/'. Yii::getAlias('@uploadFilePrices')); |
210 | 215 | } |
211 | - | |
216 | + unlink(Yii::getAlias('@uploadDir/goPrices.lock')); | |
212 | 217 | return $result; |
213 | 218 | } |
214 | 219 | |
... | ... | @@ -216,6 +221,11 @@ class Import extends Model { |
216 | 221 | |
217 | 222 | set_time_limit(0); |
218 | 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 | 230 | if ( !($handle = $this->getProductsFile('uploadFileProducts')) ) { |
221 | 231 | $this->errors[] = 'File not found'; |
... | ... | @@ -506,7 +516,7 @@ class Import extends Model { |
506 | 516 | if ($result['end']) { |
507 | 517 | unlink(Yii::getAlias('@uploadDir') .'/'. Yii::getAlias('@uploadFileProducts')); |
508 | 518 | } |
509 | - | |
519 | + unlink(Yii::getAlias('@uploadDir/goProducts.lock')); | |
510 | 520 | return $result; |
511 | 521 | } |
512 | 522 | ... | ... |
console/controllers/ImportController.php
... | ... | @@ -50,28 +50,15 @@ class ImportController extends Controller { |
50 | 50 | } |
51 | 51 | |
52 | 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 | 53 | $model = new Import(); |
60 | 54 | $model->goProducts(0, null); |
61 | - unlink(Yii::getAlias('@uploadDir/goProducts.lock')); | |
62 | 55 | return Controller::EXIT_CODE_NORMAL; |
63 | 56 | } |
64 | 57 | |
65 | 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 | 60 | $model = new Import(); |
73 | 61 | $data = $model->goPrices(0, null); |
74 | - unlink(Yii::getAlias('@uploadDir/goPrices.lock')); | |
75 | 62 | return Controller::EXIT_CODE_NORMAL; |
76 | 63 | } |
77 | 64 | ... | ... |