]> source.dussan.org Git - nextcloud-server.git/commitdiff
When moving a file from/to a temporary location, also update the file access/modifica...
authorMatthew Dawson <matthew@mjdsystems.ca>
Fri, 11 Mar 2011 17:03:30 +0000 (12:03 -0500)
committerRobin Appelman <icewind1991@gmail.com>
Thu, 17 Mar 2011 19:57:28 +0000 (20:57 +0100)
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.

lib/filestorage.php

index 3a0d124cbf23e8c4f620f86f79b0f7fb2def0659..68f232d3a607681b9cc2da721e5acc6a53c643a3 100644 (file)
@@ -360,7 +360,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{
@@ -369,7 +371,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{