From 098fc5ef95c60e5e9ff5e049d80d8dc82aef5e8a Mon Sep 17 00:00:00 2001 From: Michael Gapczynski Date: Wed, 22 Jun 2011 18:16:41 -0400 Subject: [PATCH] Fixed stat(), file?time()'s now grab most recent time from shared files --- apps/files_sharing/sharedstorage.php | 38 +++++++++++++++++++++++----- 1 file changed, 31 insertions(+), 7 deletions(-) diff --git a/apps/files_sharing/sharedstorage.php b/apps/files_sharing/sharedstorage.php index 5b2ccbd473..a66066aeb9 100644 --- a/apps/files_sharing/sharedstorage.php +++ b/apps/files_sharing/sharedstorage.php @@ -99,10 +99,10 @@ class OC_FILESTORAGE_SHARED { $stat["uid"] = ""; $stat["gid"] = ""; $stat["rdev"] = ""; - $stat["size"] = filesize($path); - $stat["atime"] = fileatime($path); - $stat["mtime"] = filemtime($path); - $stat["ctime"] = filectime($path); + $stat["size"] = OC_FILESTORAGE_SHARED::filesize($path); + $stat["atime"] = OC_FILESTORAGE_SHARED::fileatime($path); + $stat["mtime"] = OC_FILESTORAGE_SHARED::filemtime($path); + $stat["ctime"] = OC_FILESTORAGE_SHARED::filectime($path); $stat["blksize"] = ""; $stat["blocks"] = ""; return $stat; @@ -194,7 +194,15 @@ class OC_FILESTORAGE_SHARED { // TODO Get ctime of last file public function filectime($path) { if ($path == "" || $path == "/") { - return 10000003232; + $ctime = 0; + $dir = OC_FILESTORAGE_SHARED::opendir($path); + while (($filename = readdir($dir)) != false) { + $tempctime = OC_FILESTORAGE_SHARED::filectime($filename); + if ($tempctime > $ctime) { + $ctime = $tempctime; + } + } + return $ctime; } else { $source = OC_SHARE::getSource($path); if ($source) { @@ -207,7 +215,15 @@ class OC_FILESTORAGE_SHARED { // TODO Get mtime of last file public function filemtime($path) { if ($path == "" || $path == "/") { - return 10000003232; + $mtime = 0; + $dir = OC_FILESTORAGE_SHARED::opendir($path); + while (($filename = readdir($dir)) != false) { + $tempmtime = OC_FILESTORAGE_SHARED::filemtime($filename); + if ($tempmtime > $mtime) { + $mtime = $tempmtime; + } + } + return $mtime; } else { $source = OC_SHARE::getSource($path); if ($source) { @@ -220,7 +236,15 @@ class OC_FILESTORAGE_SHARED { // TODO Get atime of last file public function fileatime($path) { if ($path == "" || $path == "/") { - return 10000003232; + $atime = 0; + $dir = OC_FILESTORAGE_SHARED::opendir($path); + while (($filename = readdir($dir)) != false) { + $tempatime = OC_FILESTORAGE_SHARED::fileatime($filename); + if ($tempatime > $atime) { + $atime = $tempatime; + } + } + return $atime; } else { $source = OC_SHARE::getSource($path); if ($source) {