Skip to content

Commit

Permalink
cache the file hashname
Browse files Browse the repository at this point in the history
  • Loading branch information
themsaid committed Feb 10, 2017
1 parent 69f9c4e commit fc17481
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/Illuminate/Http/FileHelpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@

trait FileHelpers
{
/**
* The file hash name.
*
* @var string
*/
private $hashNameCache = null;

/**
* Get the fully qualified path to the file.
*
Expand Down Expand Up @@ -48,6 +55,8 @@ public function hashName($path = null)
$path = rtrim($path, '/').'/';
}

return $path.Str::random(40).'.'.$this->guessExtension();
$hash = $this->hashNameCache ?: $this->hashNameCache = Str::random(40);

return $path.$hash.'.'.$this->guessExtension();
}
}

0 comments on commit fc17481

Please sign in to comment.