Skip to content

Commit

Permalink
Merge pull request #34 from DivanteLtd/bugfix/incomplete-file-list
Browse files Browse the repository at this point in the history
Fix incomplete file list
  • Loading branch information
t-zilla authored Oct 9, 2020
2 parents 13fdf5d + 38ff9db commit 1dbce8d
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions src/PimcoreDevkitBundle/Command/SynchronizeAssetsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,20 @@ protected function execute(InputInterface $input, OutputInterface $output): void

$parentPath = substr(dirname($file), strlen(PIMCORE_ASSET_DIRECTORY)) . "/";
$filename = basename($file);
$fileModificationDate = filemtime($file);

// Does asset exist?
$asset = Asset::getByPath($parentPath . $filename);

if ($asset) {
if ($asset->getModificationDate() !== $fileModificationDate) {
$asset->setModificationDate($fileModificationDate);
$asset->save();
$output->writeln(
"Updated modification date for " . $parentPath . $filename . " (" . $asset->getType() . ")"
);
}

continue;
}

Expand All @@ -92,11 +102,13 @@ protected function execute(InputInterface $input, OutputInterface $output): void
*/
public function listFolderFiles($dir)
{
$ffs = rscandir($dir);
$files = rscandir($dir);

unset($ffs[array_search('.', $ffs, true)]);
unset($ffs[array_search('..', $ffs, true)]);

return $ffs;
return array_filter(
$files,
function ($filename) {
return $filename !== '.' && $filename !== '..';
}
);
}
}

0 comments on commit 1dbce8d

Please sign in to comment.