diff options
author | Bart Visscher <bartv@thisnet.nl> | 2012-07-27 11:40:51 +0200 |
---|---|---|
committer | Bart Visscher <bartv@thisnet.nl> | 2012-07-27 11:40:51 +0200 |
commit | a7a54331082c41c5b05cd7982c058caf1556f777 (patch) | |
tree | bc51551c2430837856cdb1f3a1e04c46e0f664cb /lib/connector/sabre/file.php | |
parent | e8010209bb1ec8ef9ecc1cff7ac2b2d4d414bd74 (diff) | |
parent | d26f87e738314db7820f39f74f42865ff20f7bd7 (diff) | |
download | nextcloud-server-a7a54331082c41c5b05cd7982c058caf1556f777.tar.gz nextcloud-server-a7a54331082c41c5b05cd7982c058caf1556f777.zip |
Merge branch 'master' into chunked_upload
Conflicts:
lib/connector/sabre/directory.php
Diffstat (limited to 'lib/connector/sabre/file.php')
-rw-r--r-- | lib/connector/sabre/file.php | 34 |
1 files changed, 30 insertions, 4 deletions
diff --git a/lib/connector/sabre/file.php b/lib/connector/sabre/file.php index dd25df78c29..9d571fceb0d 100644 --- a/lib/connector/sabre/file.php +++ b/lib/connector/sabre/file.php @@ -26,13 +26,28 @@ class OC_Connector_Sabre_File extends OC_Connector_Sabre_Node implements Sabre_D /** * Updates the data * + * The data argument is a readable stream resource. + * + * After a succesful put operation, you may choose to return an ETag. The + * etag must always be surrounded by double-quotes. These quotes must + * appear in the actual string you're returning. + * + * Clients may use the ETag from a PUT request to later on make sure that + * when they update the file, the contents haven't changed in the mean + * time. + * + * If you don't plan to store the file byte-by-byte, and you return a + * different object on a subsequent GET you are strongly recommended to not + * return an ETag, and just return null. + * * @param resource $data - * @return void + * @return string|null */ public function put($data) { OC_Filesystem::file_put_contents($this->path,$data); + return OC_Connector_Sabre_Node::getETagPropertyForPath($this->path); } /** @@ -42,7 +57,7 @@ class OC_Connector_Sabre_File extends OC_Connector_Sabre_Node implements Sabre_D */ public function get() { - return OC_Filesystem::fopen($this->path,'r'); + return OC_Filesystem::fopen($this->path,'rb'); } @@ -79,9 +94,20 @@ class OC_Connector_Sabre_File extends OC_Connector_Sabre_Node implements Sabre_D * @return mixed */ public function getETag() { + $properties = $this->getProperties(array(self::GETETAG_PROPERTYNAME)); + if (isset($properties[self::GETETAG_PROPERTYNAME])) { + return $properties[self::GETETAG_PROPERTYNAME]; + } + return $this->getETagPropertyForPath($this->path); + } - return null; - + /** + * Creates a ETag for this path. + * @param string $path Path of the file + * @return string|null Returns null if the ETag can not effectively be determined + */ + static protected function createETag($path) { + return OC_Filesystem::hash('md5', $path); } /** |