private function unpackFiles()
 {
     $this->IOHelper->writeln("Replace system files...");
     if (!is_dir(UPDATE_FILES_PATH)) {
         $this->IOHelper->writeln("skipped...");
         return;
     }
     /** @var FilesystemFactory $factory */
     $factory = $this->container->get('filesystem.factory');
     $localFilesytem = $factory->createLocalFilesystem();
     $remoteFilesystem = $factory->createLocalFilesystem();
     /** @var PathBuilder $pathBuilder */
     $pathBuilder = $this->container->get('path.builder');
     $debug = false;
     $step = new UnpackStep($localFilesytem, $remoteFilesystem, $pathBuilder, $debug);
     $offset = 0;
     $total = 0;
     do {
         $result = $step->run($offset, $total);
         if ($result instanceof ErrorResult) {
             throw new \Exception($result->getMessage(), 0, $result->getException());
         }
         $offset = $result->getOffset();
         $total = $result->getTotal();
     } while ($result instanceof ValidResult);
 }
 /**
  * @throws \RuntimeException
  */
 public function unpack()
 {
     // Manual updates do not contain files to overwrite
     if (UPDATE_IS_MANUAL) {
         Utils::clearOpcodeCache();
         $this->toJson(200, $this->resultMapper->toExtJs(new FinishResult(0, 0)));
         return;
     }
     $offset = $this->request->get('offset');
     $total = $this->request->get('total');
     /** @var FilesystemFactory $factory */
     $factory = $this->container->get('filesystem.factory');
     $localFilesystem = $factory->createLocalFilesystem();
     $remoteFilesystem = $factory->createRemoteFilesystem();
     if ($offset == 0) {
         $this->validateFilesytems($localFilesystem, $remoteFilesystem);
     }
     /** @var PathBuilder $pathBuilder */
     $pathBuilder = $this->container->get('path.builder');
     $debug = false;
     $step = new UnpackStep($localFilesystem, $remoteFilesystem, $pathBuilder, $debug);
     $result = $step->run($offset, $total);
     if ($result instanceof ValidResult) {
         Utils::clearOpcodeCache();
     }
     $this->toJson(200, $this->resultMapper->toExtJs($result));
 }