public function run()
 {
     require_once 'ModuleInstall/PackageManager/PackageManager.php';
     $pm = new PackageManager();
     $packages = $pm->getinstalledPackages(array('module'));
     foreach ($packages as $pack) {
         if (strpos($pack['name'], 'SugarCRM Upgrader') !== false) {
             $uh = new UpgradeHistory();
             $uh->name = $pack['name'];
             $history = $uh->checkForExisting($uh);
             $this->filesToRemove[] = "custom/Extension/application/Ext/Include/{$history->id_name}.php";
             $history->delete();
             $this->fileToDelete($this->filesToRemove);
             $this->log("Useless files of {$pack['name']} v{$pack['version']} removed");
         }
     }
     foreach ($pm->getPackagesInStaging() as $pack) {
         if (strpos($pack['name'], 'SugarCRM Upgrader') !== false) {
             $file = UploadStream::getFSPath(hashToFile($pack['file']));
             $this->fileToDelete($file);
             foreach (array('manifest', 'icon') as $meta) {
                 $this->fileToDelete(pathinfo($file, PATHINFO_DIRNAME) . '/' . pathinfo($file, PATHINFO_FILENAME) . "-{$meta}.php");
             }
         }
     }
 }
 public function url_stat($path, $flags)
 {
     $this->init();
     // because of php bug not calling stream ctor
     if (file_exists(parent::getFSPath($path))) {
         return parent::url_stat($path, $flags);
     }
     $stat = $this->callS3("url_stat", func_get_args());
     if (empty($stat['size'])) {
         return false;
     }
     return $stat;
 }