File tree Expand file tree Collapse file tree 4 files changed +21
-2
lines changed Expand file tree Collapse file tree 4 files changed +21
-2
lines changed Original file line number Diff line number Diff line change 1
1
{
2
2
"name" : " opcodesio/log-viewer" ,
3
- "version" : " v1.6.1 " ,
3
+ "version" : " v1.6.2 " ,
4
4
"description" : " Fast and easy-to-use log viewer for your Laravel application" ,
5
5
"keywords" : [
6
6
" arukompas" ,
Original file line number Diff line number Diff line change @@ -20,7 +20,15 @@ public function __invoke()
20
20
$ file = $ filesRequiringScans ->filter (fn ($ file ) => $ file ->sizeInMB () > 10 )->first ();
21
21
22
22
if (is_null ($ file )) {
23
- $ file = $ filesRequiringScans ->sortByDesc (fn ($ file ) => $ file ->size ())->first ();
23
+ $ file = $ filesRequiringScans
24
+ ->sortByDesc (fn ($ file ) => $ file ->size ())
25
+ ->filter (fn ($ file ) => $ file ->size () > 0 )
26
+ ->first ();
27
+ }
28
+
29
+ if (is_null ($ file )) {
30
+ // Haven't found any files that are not empty. No scan required.
31
+ return response ()->json (['requires_scan ' => false ]);
24
32
}
25
33
26
34
$ scanStart = microtime (true );
Original file line number Diff line number Diff line change @@ -579,6 +579,11 @@ public function requiresScan(): bool
579
579
580
580
public function percentScanned (): int
581
581
{
582
+ if ($ this ->file ->size () <= 0 ) {
583
+ // empty file, so assume it has been fully scanned.
584
+ return 100 ;
585
+ }
586
+
582
587
return 100 - intval (($ this ->numberOfNewBytes () / $ this ->file ->size () * 100 ));
583
588
}
584
589
Original file line number Diff line number Diff line change @@ -190,6 +190,12 @@ public function requiresScan(): bool
190
190
public function percentScanned (): int
191
191
{
192
192
$ totalFileBytes = $ this ->fileCollection ->sum ->size ();
193
+
194
+ if ($ totalFileBytes <= 0 ) {
195
+ // empty files, so assume they've been fully scanned
196
+ return 100 ;
197
+ }
198
+
193
199
$ missingScansBytes = $ this ->fileCollection ->sum (function (LogFile $ file ) {
194
200
return $ this ->getLogQueryForFile ($ file )->numberOfNewBytes ();
195
201
});
You can’t perform that action at this time.
0 commit comments