diff --git a/src/LogFile.php b/src/LogFile.php index 23087da7..74c1d856 100644 --- a/src/LogFile.php +++ b/src/LogFile.php @@ -51,7 +51,9 @@ public function logs(): LogReader public function size(): int { - return LogViewer::getFilesystem()->size($this->path); + return LogViewer::getFilesystem()->exists() + ? LogViewer::getFilesystem()->size($this->path) + : 0; } public function sizeInMB(): float @@ -104,13 +106,13 @@ public function getLastScannedFilePositionForQuery(?string $query = ''): ?int public function earliestTimestamp(): int { return $this->getMetadata('earliest_timestamp') - ?? LogViewer::getFilesystem()->lastModified($this->path); + ?? LogViewer::getFilesystem()->exists($this->path) ? LogViewer::getFilesystem()->lastModified($this->path) : 0; } public function latestTimestamp(): int { return $this->getMetadata('latest_timestamp') - ?? LogViewer::getFilesystem()->lastModified($this->path); + ?? LogViewer::getFilesystem()->exists($this->path) ? LogViewer::getFilesystem()->lastModified($this->path) : 0; } public function scan(int $maxBytesToScan = null, bool $force = false): void diff --git a/src/LogViewerService.php b/src/LogViewerService.php index 28f6a503..7f1c6ed8 100755 --- a/src/LogViewerService.php +++ b/src/LogViewerService.php @@ -73,7 +73,7 @@ protected function getFilePathsMatchingPattern($pattern) public function basePathForLogs(): string { $rootFolder = Str::of(config('log-viewer.filesystem.root')); - return empty($rootFolder) + return ($rootFolder != "") ? $rootFolder->finish('/') : $rootFolder; }