fix: a few bugs after moving code to own directory
This commit is contained in:
@@ -4,6 +4,7 @@ namespace App\Monitor\Service;
|
||||
|
||||
use Aimeos\Map;
|
||||
use Symfony\Component\DependencyInjection\Attribute\Autowire;
|
||||
use Symfony\Component\Filesystem\Filesystem;
|
||||
use Symfony\Component\Finder\Finder;
|
||||
|
||||
class MediaFiles
|
||||
@@ -14,16 +15,21 @@ class MediaFiles
|
||||
|
||||
private string $tvShowsPath;
|
||||
|
||||
private Filesystem $filesystem;
|
||||
|
||||
public function __construct(
|
||||
#[Autowire(param: 'media.movies_path')]
|
||||
string $moviesPath,
|
||||
|
||||
#[Autowire(param: 'media.tvshows_path')]
|
||||
string $tvShowsPath,
|
||||
|
||||
Filesystem $filesystem,
|
||||
) {
|
||||
$this->finder = new Finder();
|
||||
$this->moviesPath = $moviesPath;
|
||||
$this->tvShowsPath = $tvShowsPath;
|
||||
$this->filesystem = $filesystem;
|
||||
}
|
||||
|
||||
public function getMoviesPath(): string
|
||||
@@ -61,7 +67,11 @@ class MediaFiles
|
||||
if (!str_starts_with($path, $this->tvShowsPath)) {
|
||||
$path = $this->tvShowsPath . DIRECTORY_SEPARATOR . $path;
|
||||
}
|
||||
|
||||
|
||||
if (false === $this->filesystem->exists($path)) {
|
||||
$this->filesystem->mkdir($path);
|
||||
}
|
||||
|
||||
$results = [];
|
||||
foreach ($this->finder->in($path)->files() as $file) {
|
||||
if ($onlyFilenames) {
|
||||
|
||||
Reference in New Issue
Block a user