Example #1
0
 /**
  *
  * @param string|File $value entweder eine Datei die abgelegt werden soll (wird kopiert) oder der Inhalt der Datei
  * @chainable
  * @return Cache
  */
 public function store($key, $value)
 {
     $key = $this->getKey($key);
     $file = $this->getFile($key);
     if (!$this->validate($file)) {
         // new
         $file->getDirectory()->create();
     }
     // else: update
     if ($value instanceof \Webforge\Common\System\File) {
         $value->copy($file);
     } else {
         $file->writeContents($value, File::EXCLUSIVE);
         if (!$file->exists()) {
             throw new \Psc\Exception('Cannot write to file exclusively: ' . $file . ' does not exist');
         }
     }
     return $this;
 }
Example #2
0
namespace SerienLoader;

use Webforge\Common\System\Dir;
use Webforge\Common\System\File;
use Webforge\Setup\ApplicationStorage;
use Psc\System\BufferLogger;
require_once __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'bootstrap.php';
$appStorage = new ApplicationStorage('serien-loader');
$configFile = $appStorage->getFile('inc.config.php');
if ($configFile->exists()) {
    require $configFile;
} else {
    $configDistFile = new File(__DIR__ . DIRECTORY_SEPARATOR . 'inc.config.dist.php');
    $configFile->getDirectory()->create();
    $configDistFile->copy($configFile);
    print 'Bitte unbedingt die Variablen in ' . $configFile . ' anpassen!';
    exit;
}
if (!$conf['downloadDir'] || !$conf['targetDir']) {
    print 'Bitte unbedingt die Variablen downloadDir und targetDir in ' . $configFile . ' anpassen!';
    exit;
}
$reload = isset($_GET['reload']);
$update = isset($_GET['update']);
$scan = isset($_GET['scan']);
$client = new Client($conf['serienLoaderURL']);
$log = NULL;
$episodes = array();
if ($reload) {
    $organizer = new DownloadsOrganizer(new Dir($conf['downloadDir']), new Dir($conf['targetDir']), $client, new JDownloaderRPC($conf['jdownloader']['host'], $conf['jdownloader']['port']), $subtitlesManager = NULL, $log = new BufferLogger());