mirror of
https://github.com/nextcloud/server.git
synced 2026-05-19 08:25:56 -04:00
feat(file-info): encapsulate logic to get last activity in getLastActivity function
Signed-off-by: Cristian Scheid <cristianscheid@gmail.com>
This commit is contained in:
parent
c4d7546fc3
commit
a39f2f8994
5 changed files with 29 additions and 0 deletions
|
|
@ -188,6 +188,10 @@ class TrashItem implements ITrashItem {
|
|||
return $this->fileInfo->getUploadTime();
|
||||
}
|
||||
|
||||
public function getLastActivity(): int {
|
||||
return $this->fileInfo->getLastActivity();
|
||||
}
|
||||
|
||||
public function getParentId(): int {
|
||||
return $this->fileInfo->getParentId();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -412,6 +412,10 @@ class FileInfo implements \OCP\Files\FileInfo, \ArrayAccess {
|
|||
return (int) $this->data['upload_time'];
|
||||
}
|
||||
|
||||
public function getLastActivity(): int {
|
||||
return max($this->getUploadTime(), $this->getMTime());
|
||||
}
|
||||
|
||||
public function getParentId(): int {
|
||||
return $this->data['parent'] ?? -1;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -569,6 +569,13 @@ class LazyFolder implements Folder {
|
|||
return $this->__call(__FUNCTION__, func_get_args());
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getLastActivity(): int {
|
||||
return $this->__call(__FUNCTION__, func_get_args());
|
||||
}
|
||||
|
||||
public function getRelativePath($path) {
|
||||
return PathHelper::getRelativePath($this->getPath(), $path);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -495,6 +495,10 @@ class Node implements INode {
|
|||
return $this->getFileInfo()->getUploadTime();
|
||||
}
|
||||
|
||||
public function getLastActivity(): int {
|
||||
return $this->getFileInfo()->getLastActivity();
|
||||
}
|
||||
|
||||
public function getParentId(): int {
|
||||
return $this->fileInfo->getParentId();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -301,6 +301,16 @@ interface FileInfo {
|
|||
*/
|
||||
public function getUploadTime(): int;
|
||||
|
||||
/**
|
||||
* Get the last activity date as unix timestamp
|
||||
*
|
||||
* Last activity is the more recent of the upload time and the modification time
|
||||
*
|
||||
* @return int
|
||||
* @since 34.0.0
|
||||
*/
|
||||
public function getLastActivity(): int;
|
||||
|
||||
/**
|
||||
* Get the fileid or the parent folder
|
||||
* or -1 if this item has no parent folder (because it is the root)
|
||||
|
|
|
|||
Loading…
Reference in a new issue