guard against internal errors when user is not logged in
This commit is contained in:
@@ -27,6 +27,7 @@ class MainController extends Controller
|
|||||||
|
|
||||||
public function __construct($appName, IRequest $request, $UserId, IL10N $IL10N, Aria2 $aria2, Youtube $youtube)
|
public function __construct($appName, IRequest $request, $UserId, IL10N $IL10N, Aria2 $aria2, Youtube $youtube)
|
||||||
{
|
{
|
||||||
|
|
||||||
parent::__construct($appName, $request);
|
parent::__construct($appName, $request);
|
||||||
$this->appName = $appName;
|
$this->appName = $appName;
|
||||||
$this->uid = $UserId;
|
$this->uid = $UserId;
|
||||||
|
|||||||
@@ -392,14 +392,16 @@ class Helper
|
|||||||
|
|
||||||
public static function getLocalFolder(string $path): string
|
public static function getLocalFolder(string $path): string
|
||||||
{
|
{
|
||||||
//without calling this, filesystem::getLocalFolder doesn't work
|
if (self::getUID()) {
|
||||||
OC_Util::setupFS();
|
OC_Util::setupFS();
|
||||||
return Filesystem::getLocalFolder($path);
|
return Filesystem::getLocalFolder($path);
|
||||||
|
}
|
||||||
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getRealDownloadDir($uid = null): string
|
public static function getRealDownloadDir($uid = null): string
|
||||||
{
|
{
|
||||||
$dlDir = self::getDownloadDir();;
|
$dlDir = self::getDownloadDir();
|
||||||
return self::getLocalFolder($dlDir);
|
return self::getLocalFolder($dlDir);
|
||||||
}
|
}
|
||||||
public static function getRealTorrentsDir($uid = null): string
|
public static function getRealTorrentsDir($uid = null): string
|
||||||
@@ -415,7 +417,9 @@ class Helper
|
|||||||
|
|
||||||
public static function getUID(): string
|
public static function getUID(): string
|
||||||
{
|
{
|
||||||
return self::getUser()->getUID();
|
$user = self::getUser();
|
||||||
|
$uid = $user ? $user->getUID() : "";
|
||||||
|
return $uid;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getSettings($key, $default = null, int $type = Settings::TYPE['USER'])
|
public static function getSettings($key, $default = null, int $type = Settings::TYPE['USER'])
|
||||||
|
|||||||
Reference in New Issue
Block a user