-
Notifications
You must be signed in to change notification settings - Fork 19
/
update.php
38 lines (31 loc) · 999 Bytes
/
update.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<?php
/**
* ownCloud - Updater plugin
*
* @author Victor Dubiniuk
* @copyright 2013 Victor Dubiniuk victor.dubiniuk@gmail.com
*
* This file is licensed under the Affero General Public License version 3 or
* later.
*/
namespace OCA\Updater;
\OCP\JSON::checkAdminUser();
\OCP\JSON::callCheck();
set_time_limit(0);
$request = file_get_contents('php://input');
$decodedRequest = json_decode($request, true);
$packageUrl = isset($decodedRequest['url']) ? $decodedRequest['url'] : '';
$packageVersion = isset($decodedRequest['version']) ? $decodedRequest['version'] : '';
$backupPath = isset($decodedRequest['backupPath']) ? $decodedRequest['backupPath'] : '';
try {
Updater::update($packageVersion, $backupPath);
// We are done. Some cleanup
Downloader::cleanUp($packageVersion);
Updater::cleanUp();
\OCP\JSON::success();
} catch (\Exception $e){
App::log($e->getMessage());
\OCP\JSON::error(array(
'message' => (string) App::$l10n->t('Update failed.') . $e->getMessage()
));
}