summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorRoeland Jago Douma <rullzer@users.noreply.github.com>2019-11-18 15:29:49 +0100
committerGitHub <noreply@github.com>2019-11-18 15:29:49 +0100
commit5320f08cd2eab3926104a314fb76b2de222d1d7b (patch)
treedc2965325422b4fedc6f5a765004063eb8ebf61e /apps
parent497737f28f8ed176496c2ed4997ecb7d83eac2e8 (diff)
parent8800a7e89097a4994b99d8a8fc5023c53c06946e (diff)
downloadnextcloud-server-5320f08cd2eab3926104a314fb76b2de222d1d7b.tar.gz
nextcloud-server-5320f08cd2eab3926104a314fb76b2de222d1d7b.zip
Merge pull request #17765 from nextcloud/filecache-extension
Upload time and Creation time
Diffstat (limited to 'apps')
-rw-r--r--apps/dav/lib/Connector/Sabre/File.php13
-rw-r--r--apps/dav/lib/Connector/Sabre/FilesPlugin.php18
-rw-r--r--apps/dav/lib/Connector/Sabre/Node.php8
-rw-r--r--apps/files_trashbin/lib/Trash/TrashItem.php8
4 files changed, 47 insertions, 0 deletions
diff --git a/apps/dav/lib/Connector/Sabre/File.php b/apps/dav/lib/Connector/Sabre/File.php
index 2d019b46b6a..3ce305d75f3 100644
--- a/apps/dav/lib/Connector/Sabre/File.php
+++ b/apps/dav/lib/Connector/Sabre/File.php
@@ -303,6 +303,19 @@ class File extends Node implements IFile {
}
}
+ $fileInfoUpdate = [
+ 'upload_time' => time()
+ ];
+
+ // allow sync clients to send the creation time along in a header
+ if (isset($this->request->server['HTTP_X_OC_CTIME'])) {
+ $ctime = $this->sanitizeMtime($this->request->server['HTTP_X_OC_CTIME']);
+ $fileInfoUpdate['creation_time'] = $ctime;
+ $this->header('X-OC-CTime: accepted');
+ }
+
+ $this->fileView->putFileInfo($this->path, $fileInfoUpdate);
+
if ($view) {
$this->emitPostHooks($exists);
}
diff --git a/apps/dav/lib/Connector/Sabre/FilesPlugin.php b/apps/dav/lib/Connector/Sabre/FilesPlugin.php
index 99317f2bc1c..b2a0e9a31b4 100644
--- a/apps/dav/lib/Connector/Sabre/FilesPlugin.php
+++ b/apps/dav/lib/Connector/Sabre/FilesPlugin.php
@@ -70,6 +70,9 @@ class FilesPlugin extends ServerPlugin {
const HAS_PREVIEW_PROPERTYNAME = '{http://nextcloud.org/ns}has-preview';
const MOUNT_TYPE_PROPERTYNAME = '{http://nextcloud.org/ns}mount-type';
const IS_ENCRYPTED_PROPERTYNAME = '{http://nextcloud.org/ns}is-encrypted';
+ const METADATA_ETAG_PROPERTYNAME = '{http://nextcloud.org/ns}metadata_etag';
+ const UPLOAD_TIME_PROPERTYNAME = '{http://nextcloud.org/ns}upload_time';
+ const CREATION_TIME_PROPERTYNAME = '{http://nextcloud.org/ns}creation_time';
const SHARE_NOTE = '{http://nextcloud.org/ns}note';
/**
@@ -400,6 +403,14 @@ class FilesPlugin extends ServerPlugin {
return new ChecksumList($checksum);
});
+ $propFind->handle(self::CREATION_TIME_PROPERTYNAME, function() use ($node) {
+ return $node->getFileInfo()->getCreationTime();
+ });
+
+ $propFind->handle(self::UPLOAD_TIME_PROPERTYNAME, function() use ($node) {
+ return $node->getFileInfo()->getUploadTime();
+ });
+
}
if ($node instanceof \OCA\DAV\Connector\Sabre\Directory) {
@@ -470,6 +481,13 @@ class FilesPlugin extends ServerPlugin {
}
return false;
});
+ $propPatch->handle(self::CREATION_TIME_PROPERTYNAME, function($time) use ($node) {
+ if (empty($time)) {
+ return false;
+ }
+ $node->setCreationTime((int) $time);
+ return true;
+ });
}
/**
diff --git a/apps/dav/lib/Connector/Sabre/Node.php b/apps/dav/lib/Connector/Sabre/Node.php
index f0917fe11b2..2a3e8145f6f 100644
--- a/apps/dav/lib/Connector/Sabre/Node.php
+++ b/apps/dav/lib/Connector/Sabre/Node.php
@@ -201,6 +201,14 @@ abstract class Node implements \Sabre\DAV\INode {
return $this->fileView->putFileInfo($this->path, array('etag' => $etag));
}
+ public function setCreationTime(int $time) {
+ return $this->fileView->putFileInfo($this->path, array('creation_time' => $time));
+ }
+
+ public function setUploadTime(int $time) {
+ return $this->fileView->putFileInfo($this->path, array('upload_time' => $time));
+ }
+
/**
* Returns the size of the node, in bytes
*
diff --git a/apps/files_trashbin/lib/Trash/TrashItem.php b/apps/files_trashbin/lib/Trash/TrashItem.php
index 0112b6dbc8e..71830d8b91e 100644
--- a/apps/files_trashbin/lib/Trash/TrashItem.php
+++ b/apps/files_trashbin/lib/Trash/TrashItem.php
@@ -177,4 +177,12 @@ class TrashItem implements ITrashItem {
public function getTitle(): string {
return $this->getOriginalLocation();
}
+
+ public function getCreationTime(): int {
+ return $this->fileInfo->getCreationTime();
+ }
+
+ public function getUploadTime(): int {
+ return $this->fileInfo->getUploadTime();
+ }
}