mirror of
https://github.com/friendica/friendica
synced 2025-04-19 02:30:12 +00:00
Merge pull request #14297 from annando/clear-avatar
Delete cached avatar data from storage
This commit is contained in:
commit
fca67b3fcb
1 changed files with 25 additions and 0 deletions
|
@ -25,6 +25,9 @@ use Asika\SimpleConsole\CommandArgsException;
|
||||||
use Friendica\Core\Storage\Repository\StorageManager;
|
use Friendica\Core\Storage\Repository\StorageManager;
|
||||||
use Friendica\Core\Storage\Exception\ReferenceStorageException;
|
use Friendica\Core\Storage\Exception\ReferenceStorageException;
|
||||||
use Friendica\Core\Storage\Exception\StorageException;
|
use Friendica\Core\Storage\Exception\StorageException;
|
||||||
|
use Friendica\Database\DBA;
|
||||||
|
use Friendica\Model\Contact;
|
||||||
|
use Friendica\Model\Photo;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* tool to manage storage backend and stored data from CLI
|
* tool to manage storage backend and stored data from CLI
|
||||||
|
@ -57,6 +60,9 @@ Synopsis
|
||||||
bin/console storage list
|
bin/console storage list
|
||||||
List available storage backends
|
List available storage backends
|
||||||
|
|
||||||
|
bin/console storage clear
|
||||||
|
Remove the contact avatar cache data
|
||||||
|
|
||||||
bin/console storage set <name>
|
bin/console storage set <name>
|
||||||
Set current storage backend
|
Set current storage backend
|
||||||
name storage backend to use. see "list".
|
name storage backend to use. see "list".
|
||||||
|
@ -87,6 +93,9 @@ HELP;
|
||||||
case 'list':
|
case 'list':
|
||||||
return $this->doList();
|
return $this->doList();
|
||||||
break;
|
break;
|
||||||
|
case 'clear':
|
||||||
|
return $this->clear();
|
||||||
|
break;
|
||||||
case 'set':
|
case 'set':
|
||||||
return $this->doSet();
|
return $this->doSet();
|
||||||
break;
|
break;
|
||||||
|
@ -126,6 +135,22 @@ HELP;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function clear()
|
||||||
|
{
|
||||||
|
$fields = ['photo' => '', 'thumb' => '', 'micro' => ''];
|
||||||
|
$photos = DBA::select('photo', ['id', 'contact-id'], ['uid' => 0, 'photo-type' => [Photo::CONTACT_AVATAR, Photo::CONTACT_BANNER]]);
|
||||||
|
while ($photo = DBA::fetch($photos)) {
|
||||||
|
if (Photo::delete(['id' => $photo['id']])) {
|
||||||
|
Contact::update($fields, ['id' => $photo['contact-id']]);
|
||||||
|
$this->out('Cleared photo id ' . $photo['id'] . ' - contact id ' . $photo['contact-id']);
|
||||||
|
} else {
|
||||||
|
$this->out('Photo id ' . $photo['id'] . ' was not deleted.');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
DBA::close($photos);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
protected function doSet()
|
protected function doSet()
|
||||||
{
|
{
|
||||||
if (count($this->args) !== 2 || empty($this->args[1])) {
|
if (count($this->args) !== 2 || empty($this->args[1])) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue