From 629202c9ddf89d49a21cd1e27617dd7a1ddae129 Mon Sep 17 00:00:00 2001 From: Deon George Date: Tue, 1 Oct 2024 11:59:56 +1000 Subject: [PATCH] Show filename for item being scheduled for deletion, remove redundant functions --- app/Console/Commands/PhotoMove.php | 98 ------------------------------ app/Models/Abstracted/Catalog.php | 14 ----- app/Traits/Multimedia.php | 2 +- 3 files changed, 1 insertion(+), 113 deletions(-) delete mode 100644 app/Console/Commands/PhotoMove.php diff --git a/app/Console/Commands/PhotoMove.php b/app/Console/Commands/PhotoMove.php deleted file mode 100644 index be738b6..0000000 --- a/app/Console/Commands/PhotoMove.php +++ /dev/null @@ -1,98 +0,0 @@ -option('file')) { - $po = Photo::notRemove()->notDuplicate()->where('filename',Photo::path($this->option('file'))); - - } elseif ($this->option('id')) { - $po = Photo::notRemove()->notDuplicate()->where('id',$this->option('id')); - - } else { - $po = Photo::notRemove()->notDuplicate(); - } - - if (! $po) - exit; - - // Show a progress bar - $bar = $this->output->createProgressBar($po->count()); - $bar->setFormat("%current%/%max% [%bar%] %percent:3s%% (%memory%) (%remaining%) "); - $bar->setRedrawFrequency(100); - - $po->chunk(1,function($photo) use ($bar) { - while ($o = $photo->shift()) { - if (($x = $o->moveable()) === TRUE) { - Log::info(sprintf('%s: Moving (%s)[%s]',__METHOD__,$o->id,$o->filename)); - - if ($this->makeParentDir(dirname($o->file_path(FALSE,TRUE))) AND rename($o->file_path(),$o->file_path(FALSE,TRUE))) { - // Convert the path to a relative one. - $o->filename = $o->file_path(TRUE,TRUE); - - // @todo If the DB update failed, move it back. - if (! $o->save()) # AND ! rename($path,$o->file_path())) - { - $this->error(sprintf('Save after rename failed for (%s)',$o->id)); - continue; - } - - } else { - $this->error(sprintf('Rename failed for (%s)',$o->id)); - continue; - } - - chmod($o->file_path(),0444); - - } else { - if ($x > 0) - $this->warn(sprintf('Unable to move (%s) [%s] to [%s], movable returned (%s)',$o->id,$o->file_path(),$o->file_path(FALSE,TRUE),$x)); - } - } - - $bar->advance(); - }); - } -} \ No newline at end of file diff --git a/app/Models/Abstracted/Catalog.php b/app/Models/Abstracted/Catalog.php index 90dab18..a0f3290 100644 --- a/app/Models/Abstracted/Catalog.php +++ b/app/Models/Abstracted/Catalog.php @@ -298,20 +298,6 @@ abstract class Catalog extends Model return config(static::config.'.dir').DIRECTORY_SEPARATOR.($source ? $this->filename : $this->file_name()); } - /** - * Determine the new name for the image - * @deprecated use $this->file_name(FALSE) to determine the name, and file_name(TRUE) to determine the new name - */ - public function file_path($short=FALSE,$new=FALSE) - { - $file = $this->filename; - - if ($new) - $file = $this->file_name(TRUE); - - return (($short OR preg_match('/^\//',$file)) ? '' : config(static::config.'.dir').DIRECTORY_SEPARATOR).$file; - } - /** * Calculate a file path ID based on the id of the file * diff --git a/app/Traits/Multimedia.php b/app/Traits/Multimedia.php index e8702c9..7a13f9b 100644 --- a/app/Traits/Multimedia.php +++ b/app/Traits/Multimedia.php @@ -82,7 +82,7 @@ trait Multimedia switch (strtolower($request->input('type'))) { case 'photo': case 'video': - Log::info(sprintf('Dispatching delete for [%s]',$o->id)); + Log::info(sprintf('Dispatching delete for [%s] (%s)',$o->id,$o->file_name(FALSE))); CatalogDelete::dispatch($o) ->onQueue('delete');