protected function truncateDirectory($dirname, Filesystem $filesystem)
    {
        if ($dirname
            && ltrim(dirname($dirname), '.')
            && !$this->config()->get('keep_empty_dirs')
            && !$filesystem->listContents($dirname)
        ) {
            $filesystem->deleteDir($dirname);
        }
    }