From a39f2f899451e6a98756db8e76bbaa7d460e3a9e Mon Sep 17 00:00:00 2001 From: Cristian Scheid Date: Mon, 23 Mar 2026 08:58:12 -0300 Subject: [PATCH] feat(file-info): encapsulate logic to get last activity in getLastActivity function Signed-off-by: Cristian Scheid --- apps/files_trashbin/lib/Trash/TrashItem.php | 4 ++++ lib/private/Files/FileInfo.php | 4 ++++ lib/private/Files/Node/LazyFolder.php | 7 +++++++ lib/private/Files/Node/Node.php | 4 ++++ lib/public/Files/FileInfo.php | 10 ++++++++++ 5 files changed, 29 insertions(+) diff --git a/apps/files_trashbin/lib/Trash/TrashItem.php b/apps/files_trashbin/lib/Trash/TrashItem.php index 5c9775c6876..8f1668f01e6 100644 --- a/apps/files_trashbin/lib/Trash/TrashItem.php +++ b/apps/files_trashbin/lib/Trash/TrashItem.php @@ -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(); } diff --git a/lib/private/Files/FileInfo.php b/lib/private/Files/FileInfo.php index 81a283e365b..77405efbd3d 100644 --- a/lib/private/Files/FileInfo.php +++ b/lib/private/Files/FileInfo.php @@ -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; } diff --git a/lib/private/Files/Node/LazyFolder.php b/lib/private/Files/Node/LazyFolder.php index 08e77d7f705..c4ab545fc8d 100644 --- a/lib/private/Files/Node/LazyFolder.php +++ b/lib/private/Files/Node/LazyFolder.php @@ -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); } diff --git a/lib/private/Files/Node/Node.php b/lib/private/Files/Node/Node.php index 9f1a1e357e9..f4fe8224a32 100644 --- a/lib/private/Files/Node/Node.php +++ b/lib/private/Files/Node/Node.php @@ -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(); } diff --git a/lib/public/Files/FileInfo.php b/lib/public/Files/FileInfo.php index 817b03dfc65..bf5f6c71180 100644 --- a/lib/public/Files/FileInfo.php +++ b/lib/public/Files/FileInfo.php @@ -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)