From 021762ed3b44c556ddb148024838cedbf5877b78 Mon Sep 17 00:00:00 2001 From: Vincent Vanwaelscappel Date: Thu, 1 Sep 2022 18:15:46 +0200 Subject: [PATCH] wait #4209 @3 --- src/Files/Files.php | 39 +++++++++++++++++---------------------- 1 file changed, 17 insertions(+), 22 deletions(-) diff --git a/src/Files/Files.php b/src/Files/Files.php index 87a0f5c..616ece0 100644 --- a/src/Files/Files.php +++ b/src/Files/Files.php @@ -1,6 +1,9 @@ getMTime()); + $cmd = 'find ' . $dir . ' '; + if (!$recursive) { + $cmd .= '-maxdepth 1 -mindepth 1 '; } - return $time; - } - - public static function checkHashDir($dir) - { - $nb = 0; - $time = 0; - $size = 0; - - $files = self::getDirectoryIterator($dir, true); - - foreach ($files as $f) { - $time = max($time, $f->getMTime()); - $nb++; - $size += $f->getSize(); + $cmd .= '-type f '; + if (count($extensions)) { + $cmd .= '\( '; + $exts = []; + foreach ($extensions as $extension) { + $exts[] = '-name "*.' . $extension . '"'; + } + $cmd .= implode(' -o ', $exts) . ' \) '; } - - return hash('sha256', $dir . '$$' . $nb . '//' . $size . '|||' . $time); + $cmd .= '-type f -printf "%T@ %p\n" | sort -n | cut -d\' \' -f 2- | tail -n 1'; + return filemtime(trim(`$cmd`)); } /** -- 2.39.5