Esempio n. 1
0
 public function setUpdate()
 {
     Player_Debug::setDebug('Moving temporary files...');
     Player_Debug::setStatus('Updating files...');
     $label = Player_Flags::getFlag('label');
     $path = Player_Flags::getFlag('path');
     $field = Player_Flags::getFlag('field');
     $files = Player_Flags::getFlag('files');
     $step = array('media' => array('path' => $path['media'], 'temp' => $path['media'] . $path['temp'], 'files' => $this->getFiles()), 'library' => array('path' => $path['library'], 'temp' => $path['library'] . $path['temp'], 'files' => $this->getLibraries()), 'picture' => array('path' => $path['picture'], 'temp' => $path['picture'] . $path['temp'], 'files' => $this->getpics()));
     foreach ($step as $index) {
         Player_File::moveFiles($index['files'], $index['path'], $index['temp']);
         $local = Player_File::listFiles($index['path']);
         $diff = array_diff($index['files'], $local);
         Player_File::removeFiles($diff, $index['temp']);
     }
     $refresh = array('playlist', 'loop');
     Player_Debug::setDebug('Moving temporary playlist...');
     if ($this->getRefresh()) {
         foreach ($refresh as $index) {
             Player_File::moveFile($path['config'] . $files[$index]['temp'], $path['config'] . $files[$index]['file'], true);
         }
         Player_Debug::setClear();
     } else {
         foreach ($refresh as $index) {
             Player_File::unsetFile($path['config'] . $files[$index]['temp']);
         }
     }
     Player_Debug::setDebug('Deleting old files...');
     foreach ($step as $index) {
         $temp = Player_File::listFiles($index['temp']);
         Player_File::removeFiles($temp, $index['temp']);
     }
     Player_Debug::saveLog($path['config'] . $files['log']['file']);
     return true;
 }