summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBjörn Schießle <bjoern@schiessle.org>2017-11-17 14:49:06 +0100
committerGitHub <noreply@github.com>2017-11-17 14:49:06 +0100
commit19e4a3373b057a97b57368b578b7ded46895979d (patch)
treec52b62365da6483fd03e806536a25c6d8e0e8cc0
parenteeb0cfdaf52bc9929bb27040f74a66bfc18ca67c (diff)
parent1ade6b081781c961049eebd161f845d5be5a4000 (diff)
downloadnextcloud-server-19e4a3373b057a97b57368b578b7ded46895979d.tar.gz
nextcloud-server-19e4a3373b057a97b57368b578b7ded46895979d.zip
Merge pull request #7206 from nextcloud/fix-object-storage-touch
touch opertation on object storage, don't create the file cache entry to early
-rw-r--r--lib/private/Files/ObjectStore/ObjectStoreStorage.php27
1 files changed, 13 insertions, 14 deletions
diff --git a/lib/private/Files/ObjectStore/ObjectStoreStorage.php b/lib/private/Files/ObjectStore/ObjectStoreStorage.php
index 79ce7ee3247..acb8d670780 100644
--- a/lib/private/Files/ObjectStore/ObjectStoreStorage.php
+++ b/lib/private/Files/ObjectStore/ObjectStoreStorage.php
@@ -351,25 +351,24 @@ class ObjectStoreStorage extends \OC\Files\Storage\Common {
$stat['mtime'] = $mtime;
$this->getCache()->update($stat['fileid'], $stat);
} else {
- $mimeType = \OC::$server->getMimeTypeDetector()->detectPath($path);
- // create new file
- $stat = array(
- 'etag' => $this->getETag($path),
- 'mimetype' => $mimeType,
- 'size' => 0,
- 'mtime' => $mtime,
- 'storage_mtime' => $mtime,
- 'permissions' => \OCP\Constants::PERMISSION_ALL - \OCP\Constants::PERMISSION_CREATE,
- );
- $fileId = $this->getCache()->put($path, $stat);
try {
- //read an empty file from memory
+ //create a empty file, need to have at least on char to make it
+ // work with all object storage implementations
$this->file_put_contents($path, ' ');
+ $mimeType = \OC::$server->getMimeTypeDetector()->detectPath($path);
+ $stat = array(
+ 'etag' => $this->getETag($path),
+ 'mimetype' => $mimeType,
+ 'size' => 0,
+ 'mtime' => $mtime,
+ 'storage_mtime' => $mtime,
+ 'permissions' => \OCP\Constants::PERMISSION_ALL - \OCP\Constants::PERMISSION_CREATE,
+ );
+ $this->getCache()->put($path, $stat);
} catch (\Exception $ex) {
- $this->getCache()->remove($path);
$this->logger->logException($ex, [
'app' => 'objectstore',
- 'message' => 'Could not create object ' . $this->getURN($fileId) . ' for ' . $path,
+ 'message' => 'Could not create object for ' . $path,
]);
return false;
}