From 897811f69a67c0efd8bfc87a0f2e551de0618b87 Mon Sep 17 00:00:00 2001 From: Richard Dern Date: Sun, 28 Apr 2024 00:27:49 +0200 Subject: [PATCH] Bundle's ancestors are now touched as well --- app/Classes/Bundle.php | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/app/Classes/Bundle.php b/app/Classes/Bundle.php index f9d7db0..82e7ced 100644 --- a/app/Classes/Bundle.php +++ b/app/Classes/Bundle.php @@ -95,12 +95,12 @@ public function getSection(): ?Bundle public function getParent(): ?Bundle { if (!isset($this->parent)) { - $parts = preg_split('#/#', $this->path, -1, PREG_SPLIT_NO_EMPTY); + $parentPath = dirname($this->getPath()); - if (count($parts) > 0) { - $this->parent = new Bundle($parts[count($parts) - 1], $this->disk); - } else { + if ($parentPath === $this->getPath()) { $this->parent = null; + } else { + $this->parent = new Bundle($parentPath, $this->getDisk()); } } @@ -202,6 +202,12 @@ public function touch() { $this->metadata()->set('lastModified', now()->toIso8601String()); $this->saveMetadata(); + + $parent = $this->getParent(); + + if (!empty($parent)) { + $parent->touch(); + } } public function render(bool $ignoreCache = false)