Merge pull request #6960 from pixelfed/feat/emoji-cloud-storage

Feat/emoji cloud storage
pull/6961/head
Shlee 4 weeks ago committed by GitHub
commit dd007e2345
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -20,7 +20,7 @@ class EmojiMoveStorageLocalToCloud extends Command
* @var string
*/
protected $signature = 'admin:EmojiMoveStorageLocalToCloud
{--limit=1000 : Max emoji rows to process this run}
{--limit=0 : Max emoji rows to process this run (0 = no limit, process all)}
{--dry-run : Report what would happen without copying or writing}
{--keep-local : Do not delete local files after verifying the cloud copy}
{--force : Skip confirmation prompts}';
@ -76,7 +76,7 @@ class EmojiMoveStorageLocalToCloud extends Command
$query = CustomEmoji::whereNull('uri')
->whereNotNull('media_path')
->orderByDesc('id')
->limit($limit);
->when($limit > 0, fn ($q) => $q->limit($limit));
$bar = $this->output->createProgressBar($query->count());
$bar->start();

@ -146,8 +146,8 @@ return Application::configure(basePath: dirname(__DIR__))
if ((bool) config_cache('pixelfed.cloud_storage') && (bool) config_cache('media.delete_local_after_cloud')) {
// Upload any local stragglers to cloud and GC verified local copies.
$schedule->command('admin:MediaMoveStorageLocalToCloud --force --limit=500')->hourlyAt(15);
// Same for local custom emoji.
$schedule->command('admin:EmojiMoveStorageLocalToCloud --force --limit=1000')->dailyAt('04:35');
// Same for local custom emoji (no limit: keep all emoji on cloud).
$schedule->command('admin:EmojiMoveStorageLocalToCloud --force')->dailyAt('04:35');
}
if (config('import.instagram.enabled')) {

@ -0,0 +1,34 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Support\Facades\Artisan;
return new class extends Migration
{
/**
* Run the migrations.
*
* When cloud storage is enabled, custom emoji URLs resolve to the cloud
* disk. Existing emoji may still only exist locally, so move them all to
* cloud now (in one pass) to avoid a window where their URLs 404. This is
* a no-op on local-only instances.
*/
public function up(): void
{
if (! (bool) config_cache('pixelfed.cloud_storage')) {
return;
}
Artisan::call('admin:EmojiMoveStorageLocalToCloud', [
'--force' => true,
]);
}
/**
* Reverse the migrations.
*/
public function down(): void
{
//
}
};
Loading…
Cancel
Save