Skip to content

Commit

Permalink
Merge pull request #24 from iMattPro/updates
Browse files Browse the repository at this point in the history
Migration fixes
  • Loading branch information
iMattPro authored Jan 7, 2025
2 parents 76849b9 + 8ccac76 commit e14722e
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions migrations/m2_storage.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ public static function depends_on(): array

public function effectively_installed(): int
{
return $this->config->offsetExists('storage\\phpbb_pwakit\\config\\path');
return $this->config->offsetExists('storage\\phpbb_pwakit\\provider')
&& $this->config->offsetExists('storage\\phpbb_pwakit\\config\\path');
}

public function update_data(): array
Expand Down Expand Up @@ -74,16 +75,19 @@ public function add_tracked_files(): void
$this->tables['storage']
);

$storage_path = ext::PWA_ICON_DIR . '/';

// Get all files at once
$files = $extension_manager->get_finder()
->set_extensions([])
->suffix('.png')
->core_path(ext::PWA_ICON_DIR . '/')
->core_path($storage_path)
->get_files();

// Extract just the file names
$files = array_map(static function($image) {
return basename($image);
// Extract just the file paths relative to the storage dir
$files = array_map(static function($image) use ($storage_path) {
$pos = strpos($image, $storage_path);
return $pos !== false ? substr($image, $pos + strlen($storage_path)) : $image;
}, $files);

// Track each file
Expand Down

0 comments on commit e14722e

Please sign in to comment.