From: Matthew Dawson Date: Fri, 11 Mar 2011 17:03:30 +0000 (-0500) Subject: When moving a file from/to a temporary location, also update the file access/modifica... X-Git-Tag: v3.0~267^2~563 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=39292ba0538057f96145e5902d8f0f1e4428e86e;p=nextcloud-server.git When moving a file from/to a temporary location, also update the file access/modification times. When PHP moves a file across filesystem boundaries, it does not update the access/modification times. Thus do it manually so that this information is not lost. --- diff --git a/inc/lib_filestorage.php b/inc/lib_filestorage.php index 06ce26f0d23..45becf7c8f7 100644 --- a/inc/lib_filestorage.php +++ b/inc/lib_filestorage.php @@ -359,7 +359,9 @@ class OC_FILESTORAGE_LOCAL extends OC_FILESTORAGE{ public function toTmpFile($path){ $tmpFolder=sys_get_temp_dir(); $filename=tempnam($tmpFolder,'OC_TEMP_FILE_'.substr($path,strrpos($path,'.'))); + $fileStats = stat($this->datadir.$path); if(copy($this->datadir.$path,$filename)){ + touch($filename, $fileStats['mtime'], $fileStats['atime']); $this->notifyObservers($path,OC_FILEACTION_READ); return $filename; }else{ @@ -368,7 +370,9 @@ class OC_FILESTORAGE_LOCAL extends OC_FILESTORAGE{ } public function fromTmpFile($tmpFile,$path){ + $fileStats = stat($tmpFile); if(rename($tmpFile,$this->datadir.$path)){ + touch($this->datadir.$path, $fileStats['mtime'], $fileStats['atime']); $this->notifyObservers($path,OC_FILEACTION_CREATE); return true; }else{