disk.'.driver'); return [ 'storage_driver' => $driver, // Object stores do not expose filesystem free space. Never report // the VPS disk as the capacity of a remote storage provider. 'storage_free_bytes' => $driver === 'local' ? $this->freeBytes(Storage::disk($event->disk)->path('')) : -1, 'upload_temp_free_bytes' => $this->freeBytes($this->parts->temporaryDirectory()), ]; } protected function freeBytes(string $path): int { // Before the first upload, the directory may not exist yet. Its // nearest existing ancestor is on the filesystem that will hold it. while (! is_dir($path)) { $parent = dirname($path); if ($parent === $path) { return -1; } $path = $parent; } $bytes = @disk_free_space($path); return $bytes === false ? -1 : (int) $bytes; } }