<?php

namespace Torann\MediaSort\Disks;

class Local extends AbstractDisk
{
    /*
     * Used to determine if the path
     * has already been updated.
     *
     * @var string
     */
    private $root;

    /**
     * Remove an attached file.
     *
     * @param array $files
     */
    public function remove($files)
    {
        $this->setPathPrefix();

        parent::remove($files);
    }

    /**
     * Move an uploaded file to it's intended target.
     *
     * @param  string $source
     * @param  string $target
     *
     * @return void
     */
    public function move($source, $target)
    {
        $this->setPathPrefix();

        parent::move($source, $target);
    }

    /**
     * Set local path prefix from settings.
     *
     * @return void
     */
    protected function setPathPrefix()
    {
        if ($this->media->local_root && !$this->root) {
            // Interpolate path
            $this->root = $this->media->getInterpolator()
                ->interpolate($this->media->local_root);

            // Set path
            $this->filesystem->getDriver()
                ->getAdapter()
                ->setPathPrefix($this->root);
        }
    }
}
<?php

namespace Torann\MediaSort\Disks;

use Torann\MediaSort\Manager;
use Illuminate\Filesystem\FilesystemManager;

class Local extends AbstractDisk
{
    /**
     * Constructor method
     *
     * @param Manager           $media
     * @param FilesystemManager $filesystem
     */
    function __construct(Manager $media, FilesystemManager $filesystem)
    {
        parent::__construct($media, $filesystem);

        // Create a new instance of the local driver. Doing this will prevent
        // any setting changes made here from affecting the whole application.
        $this->filesystem = $filesystem->createLocalDriver($this->config);

        // Change the prefix of the local storage
        $this->setPathPrefix();
    }

    /**
     * Set local path prefix from settings.
     *
     * @return void
     */
    protected function setPathPrefix()
    {
        if ($this->media->local_root) {
            // Interpolate path
            $root = $this->media->getInterpolator()
                ->interpolate($this->media->local_root);

            // Set path
            $this->filesystem->getDriver()
                ->getAdapter()
                ->setPathPrefix($root);
        }
    }
}
Fix local storage config bug
Fix local storage config bug
