Skip to content

Commit

Permalink
Merge pull request #71 from spektra2147/2.7
Browse files Browse the repository at this point in the history
upgrade Laravel 10
  • Loading branch information
RyanThompson authored Nov 15, 2023
2 parents 3f8abce + e6aa89d commit 7324147
Show file tree
Hide file tree
Showing 15 changed files with 347 additions and 390 deletions.
26 changes: 11 additions & 15 deletions src/Console/Sync.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
use Anomaly\FilesModule\Folder\Contract\FolderInterface;
use Anomaly\FilesModule\Folder\Contract\FolderRepositoryInterface;
use Illuminate\Console\Command;
use Illuminate\Filesystem\FilesystemManager;
use League\Flysystem\File;
use League\Flysystem\MountManager;

/**
* Class Sync
Expand Down Expand Up @@ -35,38 +35,34 @@ class Sync extends Command
/**
* Handle the command.
*
* @param MountManager $manager
* @param FilesystemManager $manager
* @param FileSynchronizer $synchronizer
* @param FolderRepositoryInterface $folders
* @param FileRepositoryInterface $files
*/
public function handle(
MountManager $manager,
FilesystemManager $manager,
FileSynchronizer $synchronizer,
FolderRepositoryInterface $folders,
FileRepositoryInterface $files
) {
/* @var FolderInterface $folder */
foreach ($folders->all() as $folder) {

$contents = array_filter(
$manager->listContents($folder->path()),
function (array $file) {
return $file['type'] == 'file';
}
);
$contents = $manager->disk($folder->getDisk()->getSlug())->listContents($folder->getSlug(), false);

$contents = $contents->filter(function ($file) {
return $file->type() == 'file';
});

$this->info('Checking:' . $folder->path());

foreach ($contents as $file) {
if (!$files->findByNameAndFolder($file['basename'], $folder)) {

/* @var File $resource */
$resource = $manager->get($path = $folder->path($file['basename']));
if (!$files->findByNameAndFolder(basename($file->path()), $folder)) {

$synchronizer->sync($resource, $folder->getDisk());
$synchronizer->sync($file, $folder->getDisk());

$this->info('Synced: ' . $path);
$this->info('Synced: ' . $file->path());
}
}
}
Expand Down
Loading

0 comments on commit 7324147

Please sign in to comment.