fixed issues with nc24(close #60);other improvements
This commit is contained in:
@@ -94,7 +94,7 @@ class YoutubeController extends Controller
|
||||
}
|
||||
$yt->dbDlPath = Helper::getDownloadDir();
|
||||
$resp = $yt->forceIPV4()->download($url);
|
||||
folderScan::sync();
|
||||
folderScan::sync(true);
|
||||
return new JSONResponse($resp);
|
||||
}
|
||||
private function downloadUrlSite($url)
|
||||
|
||||
@@ -9,6 +9,7 @@ use OCA\NCDownloader\Tools\Settings;
|
||||
use OCP\IUser;
|
||||
use OC\Files\Filesystem;
|
||||
use OC_Util;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
class Helper
|
||||
{
|
||||
@@ -113,8 +114,7 @@ class Helper
|
||||
|
||||
public static function cleanString($string)
|
||||
{
|
||||
$replace = array
|
||||
(
|
||||
$replace = array(
|
||||
'/[áàâãªä]/u' => 'a',
|
||||
'/[ÁÀÂÃÄ]/u' => 'A',
|
||||
'/[ÍÌÎÏ]/u' => 'I',
|
||||
@@ -502,4 +502,24 @@ class Helper
|
||||
{
|
||||
return self::getSettings('ncd_downloader_dir', "/Downloads");
|
||||
}
|
||||
public static function getVersion(): array
|
||||
{
|
||||
return \OC_Util::getVersion();
|
||||
}
|
||||
public static function isLegacyVersion(): bool
|
||||
{
|
||||
return (version_compare(implode(".", self::getVersion()), '20.0.0') <= 0);
|
||||
}
|
||||
public static function query($key)
|
||||
{
|
||||
return self::isLegacyVersion() ? \OC::$server->query($key) : \OC::$server->get($key);
|
||||
}
|
||||
public static function getLogger()
|
||||
{
|
||||
return (version_compare(implode(".", self::getVersion()), '24.0.0') <= 0) ? \OC::$server->getLogger() : \OC::$server->get(LoggerInterface::class);
|
||||
}
|
||||
public static function getDatabaseConnection()
|
||||
{
|
||||
return self::isLegacyVersion() ? \OC::$server->getDatabaseConnection() : \OC::$server->get(\OCP\IDBConnection::class);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
namespace OCA\NCDownloader\Tools;
|
||||
|
||||
use OCA\NCDownloader\Tools\Helper;
|
||||
@@ -48,8 +49,8 @@ class folderScan
|
||||
//force update
|
||||
public function scan()
|
||||
{
|
||||
$this->logger = \OC::$server->getLogger();
|
||||
$this->scanner = new Scanner($this->user, \OC::$server->getDatabaseConnection(), \OC::$server->query(IEventDispatcher::class), $this->logger);
|
||||
$this->logger = Helper::getLogger();
|
||||
$this->scanner = new Scanner($this->user, Helper::getDatabaseConnection(), Helper::query(IEventDispatcher::class), $this->logger);
|
||||
try {
|
||||
$this->scanner->scan($this->path);
|
||||
return ['status' => true, 'path' => $this->path];
|
||||
@@ -64,8 +65,9 @@ class folderScan
|
||||
}
|
||||
|
||||
//update only folder is modified
|
||||
public static function sync($path = null, $user = null)
|
||||
public static function sync($force = false, $path = null, $user = null)
|
||||
{
|
||||
return self::create($path, $user)->update();
|
||||
$inst = self::create($path, $user);
|
||||
return $force ? $inst->scan() : $inst->update();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user