protected function rewriting($from)
    {
        $fs = $this->getContainer()->get('filesystem');
        try {
            $fs->remove(
                Finder::create()
                    ->files()
                    ->ignoreUnreadableDirs()
                    ->in($this->getContainer()->getParameter('kernel.root_dir').'/../src')
                    ->in($this->getContainer()->getParameter('kernel.root_dir'))
            );
        } catch (\Exception $e) {
            // ignore errors during the removal of the old application
        }

        // copy new version
        $fs->mirror(
            $from,
            $this->getContainer()->getParameter('kernel.root_dir').'/../',
            null,
            ['override' => true, 'copy_on_windows' => true]
        );

        // remove downloaded files
        $fs->remove($from);
    }