Skip to content

Commit

Permalink
Bump to 2.6.0
Browse files Browse the repository at this point in the history
  • Loading branch information
mmikkel committed Feb 24, 2024
1 parent baf9f44 commit 1e767f6
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# AssetMate Changelog

## 2.6.0 - 2024-02-24
### Changed
- The `assetmate/purge/assets` controller now deletes unused, soft-deleted assets as well
- The `assetmate/purge/folders` controller no longer cares about soft-deleted assets
- The prompt to purge empty folders after purging empty assets no longer defaults to Yes

## 2.5.0 - 2024-02-22
### Added
- Added support for validating image dimensions
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "vaersaagod/assetmate",
"description": "Protect your assets, mate!",
"type": "craft-plugin",
"version": "2.5.0",
"version": "2.6.0",
"keywords": [
"craft",
"cms",
Expand Down
9 changes: 2 additions & 7 deletions src/console/controllers/PurgeController.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ public function actionAssets(): int
$query = (new Query())
->select('assets.id')
->from(Table::ASSETS . ' AS assets')
->innerJoin(Table::ELEMENTS . ' AS elements', 'assets.id = elements.id AND elements.dateDeleted IS NULL') // Excluding assets that are already soft-deleted
->where(['NOT EXISTS', (new Query())
->from(Table::USERS . ' AS users')
->where('assets.id = users.photoId')
Expand Down Expand Up @@ -152,11 +151,6 @@ public function actionAssets(): int

$assetsWithoutRelationsCount = $query->count();

if (!$assetsWithoutRelationsCount) {
$this->stdout("No unused assets found 🎉" . PHP_EOL, BaseConsole::FG_PURPLE);
return ExitCode::OK;
}

$this->stdout("Found {$assetsWithoutRelationsCount} assets without any source element relations.\n", BaseConsole::FG_PURPLE);

if ($this->searchContentTables) {
Expand Down Expand Up @@ -303,7 +297,7 @@ public function actionAssets(): int
$this->stdout(PHP_EOL);

// Purge empty folders?
if ($this->deleteEmptyFolders && (!$this->interactive || $this->confirm("Do you want to scan for and delete empty folders?", true))) {
if ($this->deleteEmptyFolders && (!$this->interactive || $this->confirm("Do you want to scan for and delete empty folders?"))) {
$this->stdout(PHP_EOL);
$this->stdout("Searching for empty folders to purge...\n", BaseConsole::FG_YELLOW);
if ($this->actionFolders() === ExitCode::OK) {
Expand Down Expand Up @@ -347,6 +341,7 @@ public function actionFolders(): int
$query
->andWhere(['NOT EXISTS', (new Query())
->from(Table::ASSETS . ' AS assets')
->innerJoin(Table::ELEMENTS . ' AS elements', 'assets.id = elements.id AND elements.dateDeleted IS NULL') // Excluding assets that are soft-deleted
->where('folders.id = assets.folderId')
]);

Expand Down

0 comments on commit 1e767f6

Please sign in to comment.