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)