update.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. <?php
  2. set_time_limit(0);
  3. $RUNTIME_NOAPPS = true;
  4. require_once '../../lib/base.php';
  5. if (OC::checkUpgrade(false)) {
  6. $l = new \OC_L10N('core');
  7. $eventSource = new OC_EventSource();
  8. $updater = new \OC\Updater(\OC_Log::$object);
  9. $updater->listen('\OC\Updater', 'maintenanceStart', function () use ($eventSource, $l) {
  10. $eventSource->send('success', (string)$l->t('Turned on maintenance mode'));
  11. });
  12. $updater->listen('\OC\Updater', 'maintenanceEnd', function () use ($eventSource, $l) {
  13. $eventSource->send('success', (string)$l->t('Turned off maintenance mode'));
  14. });
  15. $updater->listen('\OC\Updater', 'dbUpgrade', function () use ($eventSource, $l) {
  16. $eventSource->send('success', (string)$l->t('Updated database'));
  17. });
  18. $updater->listen('\OC\Updater', 'filecacheStart', function () use ($eventSource, $l) {
  19. $eventSource->send('success', (string)$l->t('Updating filecache, this may take really long...'));
  20. });
  21. $updater->listen('\OC\Updater', 'filecacheDone', function () use ($eventSource, $l) {
  22. $eventSource->send('success', (string)$l->t('Updated filecache'));
  23. });
  24. $updater->listen('\OC\Updater', 'filecacheProgress', function ($out) use ($eventSource, $l) {
  25. $eventSource->send('success', (string)$l->t('... %d%% done ...', array('percent' => $out)));
  26. });
  27. $updater->listen('\OC\Updater', 'failure', function ($message) use ($eventSource) {
  28. $eventSource->send('failure', $message);
  29. $eventSource->close();
  30. OC_Config::setValue('maintenance', false);
  31. });
  32. $updater->upgrade();
  33. $eventSource->send('done', '');
  34. $eventSource->close();
  35. }