de-deplicate getUidAndFilename
This commit is contained in:
parent
fd2e1086c6
commit
300eb54c87
|
@ -28,6 +28,7 @@
|
||||||
*/
|
*/
|
||||||
namespace OCA\Files_Sharing;
|
namespace OCA\Files_Sharing;
|
||||||
|
|
||||||
|
use OC\Files\Filesystem;
|
||||||
use OCP\Files\NotFoundException;
|
use OCP\Files\NotFoundException;
|
||||||
|
|
||||||
class Helper {
|
class Helper {
|
||||||
|
@ -205,14 +206,7 @@ class Helper {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getUidAndFilename($filename) {
|
public static function getUidAndFilename($filename) {
|
||||||
$uid = \OC\Files\Filesystem::getOwner($filename);
|
return Filesystem::getView()->getUidAndFilename($filename);
|
||||||
\OC\Files\Filesystem::initMountPoints($uid);
|
|
||||||
if ( $uid != \OCP\User::getUser() ) {
|
|
||||||
$info = \OC\Files\Filesystem::getFileInfo($filename);
|
|
||||||
$ownerView = new \OC\Files\View('/'.$uid.'/files');
|
|
||||||
$filename = $ownerView->getPath($info['fileid']);
|
|
||||||
}
|
|
||||||
return array($uid, $filename);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -71,18 +71,7 @@ class Trashbin {
|
||||||
* @throws \OC\User\NoUserException
|
* @throws \OC\User\NoUserException
|
||||||
*/
|
*/
|
||||||
public static function getUidAndFilename($filename) {
|
public static function getUidAndFilename($filename) {
|
||||||
$uid = \OC\Files\Filesystem::getOwner($filename);
|
return Filesystem::getView()->getUidAndFilename($filename);
|
||||||
\OC\Files\Filesystem::initMountPoints($uid);
|
|
||||||
if ($uid != \OCP\User::getUser()) {
|
|
||||||
$info = \OC\Files\Filesystem::getFileInfo($filename);
|
|
||||||
$ownerView = new \OC\Files\View('/' . $uid . '/files');
|
|
||||||
try {
|
|
||||||
$filename = $ownerView->getPath($info['fileid']);
|
|
||||||
} catch (NotFoundException $e) {
|
|
||||||
$filename = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return [$uid, $filename];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -41,6 +41,7 @@
|
||||||
|
|
||||||
namespace OCA\Files_Versions;
|
namespace OCA\Files_Versions;
|
||||||
|
|
||||||
|
use OC\Files\Filesystem;
|
||||||
use OCA\Files_Versions\AppInfo\Application;
|
use OCA\Files_Versions\AppInfo\Application;
|
||||||
use OCA\Files_Versions\Command\Expire;
|
use OCA\Files_Versions\Command\Expire;
|
||||||
use OCP\Lock\ILockingProvider;
|
use OCP\Lock\ILockingProvider;
|
||||||
|
@ -81,18 +82,7 @@ class Storage {
|
||||||
* @throws \OC\User\NoUserException
|
* @throws \OC\User\NoUserException
|
||||||
*/
|
*/
|
||||||
public static function getUidAndFilename($filename) {
|
public static function getUidAndFilename($filename) {
|
||||||
$uid = \OC\Files\Filesystem::getOwner($filename);
|
return Filesystem::getView()->getUidAndFilename($filename);
|
||||||
\OC\Files\Filesystem::initMountPoints($uid);
|
|
||||||
if ( $uid != \OCP\User::getUser() ) {
|
|
||||||
$info = \OC\Files\Filesystem::getFileInfo($filename);
|
|
||||||
$ownerView = new \OC\Files\View('/'.$uid.'/files');
|
|
||||||
try {
|
|
||||||
$filename = $ownerView->getPath($info['fileid']);
|
|
||||||
} catch (NotFoundException $e) {
|
|
||||||
$filename = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return [$uid, $filename];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -44,7 +44,6 @@
|
||||||
namespace OC\Files;
|
namespace OC\Files;
|
||||||
|
|
||||||
use Icewind\Streams\CallbackWrapper;
|
use Icewind\Streams\CallbackWrapper;
|
||||||
use OC\Files\Cache\Updater;
|
|
||||||
use OC\Files\Mount\MoveableMount;
|
use OC\Files\Mount\MoveableMount;
|
||||||
use OC\Files\Storage\Storage;
|
use OC\Files\Storage\Storage;
|
||||||
use OC\User\User;
|
use OC\User\User;
|
||||||
|
@ -2017,4 +2016,28 @@ class View {
|
||||||
}
|
}
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $filename
|
||||||
|
* @return array
|
||||||
|
* @throws \OC\User\NoUserException
|
||||||
|
* @throws NotFoundException
|
||||||
|
*/
|
||||||
|
public function getUidAndFilename($filename) {
|
||||||
|
$info = $this->getFileInfo($filename);
|
||||||
|
if (!$info instanceof \OCP\Files\FileInfo) {
|
||||||
|
throw new NotFoundException($this->getAbsolutePath($filename) . 'not found');
|
||||||
|
}
|
||||||
|
$uid = $info->getOwner()->getUID();
|
||||||
|
if ($uid != \OCP\User::getUser()) {
|
||||||
|
Filesystem::initMountPoints($uid);
|
||||||
|
$ownerView = new View('/' . $uid . '/files');
|
||||||
|
try {
|
||||||
|
$filename = $ownerView->getPath($info['fileid']);
|
||||||
|
} catch (NotFoundException $e) {
|
||||||
|
throw new NotFoundException('File with id ' . $info['fileid'] . 'not found for user ' . $uid);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return [$uid, $filename];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue