Skip to content

Commit 7438101

Browse files
author
Roshan
committed
fix : unlink log file once the output has been saved in database
1 parent 980d9e8 commit 7438101

File tree

6 files changed

+19
-18
lines changed

6 files changed

+19
-18
lines changed
Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
<?php
22

3-
namespace Studio\Totem\Events\Tasks;
3+
namespace Studio\Totem\Events;
44

55
use Studio\Totem\Task;
6-
use Studio\Totem\Events\Event;
76
use Studio\Totem\Notifications\TaskCompleted;
87

98
class Executed extends Event
@@ -12,13 +11,13 @@ class Executed extends Event
1211
* Executed constructor.
1312
*
1413
* @param Task $task
15-
* @param string $start
14+
* @param string $started
1615
*/
17-
public function __construct(Task $task, $start)
16+
public function __construct(Task $task, $started)
1817
{
1918
parent::__construct($task);
2019

21-
$time_elapsed_secs = microtime(true) - $start;
20+
$time_elapsed_secs = microtime(true) - $started;
2221

2322
$output = file_get_contents(storage_path($task->getMutexName()));
2423

@@ -27,6 +26,8 @@ public function __construct(Task $task, $start)
2726
'result' => $output,
2827
]);
2928

29+
unlink(storage_path($task->getMutexName()));
30+
3031
$task->notify(new TaskCompleted($output));
3132
}
3233
}

src/Events/Executing.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?php
2+
3+
namespace Studio\Totem\Events;
4+
5+
class Executing extends Event
6+
{
7+
}

src/Events/Tasks/Executing.php

Lines changed: 0 additions & 9 deletions
This file was deleted.

src/Providers/ConsoleServiceProvider.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
namespace Studio\Totem\Providers;
44

5+
use Studio\Totem\Events\Executed;
6+
use Studio\Totem\Events\Executing;
57
use Illuminate\Support\ServiceProvider;
6-
use Studio\Totem\Events\Tasks\Executed;
7-
use Studio\Totem\Events\Tasks\Executing;
88
use Illuminate\Console\Scheduling\Schedule;
99

1010
class ConsoleServiceProvider extends ServiceProvider

src/Repositories/EloquentTaskRepository.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@
77
use Studio\Totem\Events\Deleted;
88
use Studio\Totem\Events\Updated;
99
use Studio\Totem\Events\Creating;
10+
use Studio\Totem\Events\Executed;
1011
use Studio\Totem\Events\Updating;
1112
use Studio\Totem\Events\Activated;
1213
use Studio\Totem\Events\Deactivated;
1314
use Illuminate\Support\Facades\Cache;
1415
use Illuminate\Support\Facades\Artisan;
15-
use Studio\Totem\Events\Tasks\Executed;
1616
use Studio\Totem\Contracts\TaskInterface;
1717

1818
class EloquentTaskRepository implements TaskInterface

src/Traits/HasFrequencies.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,9 @@ public function afterSave()
6767
*/
6868
public function beforeDelete()
6969
{
70-
$this->frequencies()->delete();
70+
$this->frequencies->each(function ($frequency) {
71+
$frequency->delete();
72+
});
7173

7274
$this->results()->delete();
7375
}

0 commit comments

Comments
 (0)