remove user parameter from ITrashItem::getOriginalLocation

since the target user is known at the time of creating the trashitem
the original location can already be adjusted on a per user level

Signed-off-by: Robin Appelman <robin@icewind.nl>
This commit is contained in:
Robin Appelman 2018-10-17 14:58:02 +02:00
parent a369adb4cd
commit 136113a22b
No known key found for this signature in database
GPG key ID: 42B69D8A64526EFB
3 changed files with 8 additions and 9 deletions

View file

@ -37,13 +37,12 @@ interface ITrashItem extends FileInfo {
public function getTrashBackend(): ITrashBackend;
/**
* Get the original location for the trash item for the user
* Get the original location for the trash item
*
* @param IUser $user
* @return string
* @since 15.0.0
*/
public function getOriginalLocation(IUser $user): string;
public function getOriginalLocation(): string;
/**
* Get the timestamp that the file was moved to trash

View file

@ -49,13 +49,13 @@ class LegacyTrashBackend implements ITrashBackend {
* @param ITrashItem $parent
* @return ITrashItem[]
*/
private function mapTrashItems(array $items, IUser $user, ITrashItem $parent = null): array {
private function mapTrashItems(array $items, ITrashItem $parent = null): array {
$parentTrashPath = ($parent instanceof ITrashItem) ? $parent->getTrashPath() : '';
$isRoot = $parent === null;
return array_map(function (FileInfo $file) use ($parent, $parentTrashPath, $isRoot, $user) {
return array_map(function (FileInfo $file) use ($parent, $parentTrashPath, $isRoot) {
return new TrashItem(
$this,
$isRoot ? $file['extraData'] : $parent->getOriginalLocation($user) . '/' . $file->getName(),
$isRoot ? $file['extraData'] : $parent->getOriginalLocation() . '/' . $file->getName(),
$file->getMTime(),
$parentTrashPath . '/' . $file->getName() . ($isRoot ? '.d' . $file->getMtime() : ''),
$file
@ -65,12 +65,12 @@ class LegacyTrashBackend implements ITrashBackend {
public function listTrashRoot(IUser $user): array {
$entries = Helper::getTrashFiles('/', $user->getUID());
return $this->mapTrashItems($entries, $user, null);
return $this->mapTrashItems($entries);
}
public function listTrashFolder(IUser $user, ITrashItem $folder): array {
$entries = Helper::getTrashFiles($folder->getTrashPath(), $user->getUID());
return $this->mapTrashItems($entries, $user, $folder);
return $this->mapTrashItems($entries, $folder);
}
public function restoreItem(ITrashItem $item) {

View file

@ -57,7 +57,7 @@ class TrashItem implements ITrashItem {
return $this->backend;
}
public function getOriginalLocation(IUser $user): string {
public function getOriginalLocation(): string {
return $this->orignalLocation;
}