aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files_external/lib/smb.php
diff options
context:
space:
mode:
authorRobin Appelman <icewind@owncloud.com>2012-06-17 02:54:23 +0200
committerRobin Appelman <icewind@owncloud.com>2012-06-17 02:54:23 +0200
commit769cbe9a4cc5b105cc0277057b21e4661bd9c890 (patch)
treef58bf2c0b4a076a11b3ae1a6f1f958c1c1f9c7c4 /apps/files_external/lib/smb.php
parent5b6229544d03e59085918151abd010f2700b84f2 (diff)
downloadnextcloud-server-769cbe9a4cc5b105cc0277057b21e4661bd9c890.tar.gz
nextcloud-server-769cbe9a4cc5b105cc0277057b21e4661bd9c890.zip
improve filecache support for smb
Diffstat (limited to 'apps/files_external/lib/smb.php')
-rw-r--r--apps/files_external/lib/smb.php44
1 files changed, 43 insertions, 1 deletions
diff --git a/apps/files_external/lib/smb.php b/apps/files_external/lib/smb.php
index 9112655194a..e05d69f7844 100644
--- a/apps/files_external/lib/smb.php
+++ b/apps/files_external/lib/smb.php
@@ -47,6 +47,48 @@ class OC_FileStorage_SMB extends OC_FileStorage_StreamWrapper{
$path=substr($path,0,-1);
}
return 'smb://'.$this->user.':'.$this->password.'@'.$this->host.$this->share.$this->root.$path;
-
+ }
+
+ public function stat($path){
+ if(!$path and $this->root=='/'){//mtime doesn't work for shares
+ $mtime=$this->shareMTime();
+ $stat=stat($this->constructUrl($path));
+ $stat['mtime']=$mtime;
+ return $stat;
+ }else{
+ return stat($this->constructUrl($path));
+ }
+ }
+
+ /**
+ * check if a file or folder has been updated since $time
+ * @param int $time
+ * @return bool
+ */
+ public function hasUpdated($path,$time){
+ if(!$path and $this->root=='/'){
+ //mtime doesn't work for shares, but giving the nature of the backend, doing a full update is still just fast enough
+ return true;
+ }else{
+ $actualTime=$this->filemtime($path);
+ return $actualTime>$time;
+ }
+ }
+
+ /**
+ * get the best guess for the modification time of the share
+ */
+ private function shareMTime(){
+ $dh=$this->opendir('');
+ $lastCtime=0;
+ while($file=readdir($dh)){
+ if($file!='.' and $file!='..'){
+ $ctime=$this->filemtime($file);
+ if($ctime>$lastCtime){
+ $lastCtime=$ctime;
+ }
+ }
+ }
+ return $lastCtime;
}
}