Added Files Trait, added createParentDirs

This commit is contained in:
Deon George
2016-07-01 12:19:17 +10:00
parent 90c4468c43
commit b8be45b42c
5 changed files with 90 additions and 69 deletions

View File

@@ -9,6 +9,8 @@ use App\Model\Photo;
class Move extends Command
{
use \App\Traits\Files;
/**
* The name and signature of the console command.
*
@@ -55,6 +57,9 @@ class Move extends Command
$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%) ");
@@ -66,7 +71,7 @@ class Move extends Command
if (($x = $po->moveable()) === TRUE) {
Log::info(sprintf('%s: Moving (%s)[%s]',__METHOD__,$po->id,$po->filename));
if (rename($po->file_path(),$po->file_path(FALSE,TRUE)))
if ($this->makeParentDir(dirname($po->file_path(FALSE,TRUE))) AND rename($po->file_path(),$po->file_path(FALSE,TRUE)))
{
// Convert the path to a relative one.
$po->filename = $po->file_path(TRUE,TRUE);