From 0bab8935c95c249405f5b12f4724d189c4ec648b Mon Sep 17 00:00:00 2001 From: Bjoern Schiessle Date: Mon, 12 Aug 2013 14:30:43 +0200 Subject: preserve mtime if file gets encrypted/decrypted --- apps/files_encryption/lib/util.php | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'apps') diff --git a/apps/files_encryption/lib/util.php b/apps/files_encryption/lib/util.php index 8819b0f972a..9d351983e2a 100644 --- a/apps/files_encryption/lib/util.php +++ b/apps/files_encryption/lib/util.php @@ -777,6 +777,9 @@ class Util { //relative to /data $rawPath = $encryptedFile['path']; + //get timestamp + $timestamp = $this->view->filemtime($rawPath); + //enable proxy to use OC\Files\View to access the original file \OC_FileProxy::$enabled = true; @@ -818,6 +821,9 @@ class Util { $this->view->chroot($fakeRoot); + //set timestamp + $this->view->touch($rawPath, $timestamp); + // Add the file to the cache \OC\Files\Filesystem::putFileInfo($relPath, array( 'encrypted' => false, @@ -875,10 +881,13 @@ class Util { //relative to data//file $relPath = $plainFile['path']; - + //relative to /data $rawPath = '/' . $this->userId . '/files/' . $plainFile['path']; + // keep timestamp + $timestamp = $this->view->filemtime($rawPath); + // Open plain file handle for binary reading $plainHandle = $this->view->fopen($rawPath, 'rb'); @@ -897,6 +906,9 @@ class Util { $this->view->rename($relPath . '.part', $relPath); $this->view->chroot($fakeRoot); + + // set timestamp + $this->view->touch($rawPath, $timestamp); // Add the file to the cache \OC\Files\Filesystem::putFileInfo($relPath, array( -- cgit v1.2.3