Merge pull request #5155 from mikenz/patch-3

Don't delete all assets when uploading a file in the root
This commit is contained in:
Damian Mooyman 2016-03-08 13:35:00 +13:00
commit 016ea2efb1

View File

@ -330,6 +330,7 @@ class FlysystemAssetStore implements AssetStore, AssetStoreRouter, Flushable {
*/
protected function truncateDirectory($dirname, Filesystem $filesystem) {
if ($dirname
&& ltrim(dirname($dirname), '.')
&& ! Config::inst()->get(get_class($this), 'keep_empty_dirs')
&& ! $filesystem->listContents($dirname)
) {
@ -346,7 +347,8 @@ class FlysystemAssetStore implements AssetStore, AssetStoreRouter, Flushable {
* @return Generator
*/
protected function findVariants($fileID, Filesystem $filesystem) {
foreach($filesystem->listContents(dirname($fileID)) as $next) {
$dirname = ltrim(dirname($fileID), '.');
foreach($filesystem->listContents($dirname) as $next) {
if($next['type'] !== 'file') {
continue;
}