diff options
author | Arthur Schiwon <blizzz@arthur-schiwon.de> | 2023-06-01 17:33:50 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-06-01 17:33:50 +0200 |
commit | a845fc739519926775dd461d24a874aad2b6ab82 (patch) | |
tree | a8bd608cab6658a2d5977f7b52edc285dea95147 | |
parent | f5d5636272c2a0c0d0c4bfdac8e5af459973d154 (diff) | |
parent | 780a744e07b3c10d6a2c0058f1a273bb3c38fffc (diff) | |
download | nextcloud-server-a845fc739519926775dd461d24a874aad2b6ab82.tar.gz nextcloud-server-a845fc739519926775dd461d24a874aad2b6ab82.zip |
Merge pull request #38449 from nextcloud/backport/38415/stable27
[stable27] don't always check if we need to setup the object store root
-rw-r--r-- | lib/private/Files/ObjectStore/ObjectStoreStorage.php | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/lib/private/Files/ObjectStore/ObjectStoreStorage.php b/lib/private/Files/ObjectStore/ObjectStoreStorage.php index ea60de137d2..978b5b0451c 100644 --- a/lib/private/Files/ObjectStore/ObjectStoreStorage.php +++ b/lib/private/Files/ObjectStore/ObjectStoreStorage.php @@ -87,17 +87,13 @@ class ObjectStoreStorage extends \OC\Files\Storage\Common implements IChunkedFil if (isset($params['validateWrites'])) { $this->validateWrites = (bool)$params['validateWrites']; } - //initialize cache with root directory in cache - if (!$this->is_dir('/')) { - $this->mkdir('/'); - } $this->logger = \OC::$server->getLogger(); } - public function mkdir($path) { + public function mkdir($path, bool $force = false) { $path = $this->normalizePath($path); - if ($this->file_exists($path)) { + if (!$force && $this->file_exists($path)) { $this->logger->warning("Tried to create an object store folder that already exists: $path"); return false; } @@ -246,6 +242,13 @@ class ObjectStoreStorage extends \OC\Files\Storage\Common implements IChunkedFil if ($cacheEntry instanceof CacheEntry) { return $cacheEntry->getData(); } else { + if ($path === '') { + $this->mkdir('', true); + $cacheEntry = $this->getCache()->get($path); + if ($cacheEntry instanceof CacheEntry) { + return $cacheEntry->getData(); + } + } return false; } } @@ -357,6 +360,12 @@ class ObjectStoreStorage extends \OC\Files\Storage\Common implements IChunkedFil case 'wb': case 'w+': case 'wb+': + $dirName = dirname($path); + $parentExists = $this->is_dir($dirName); + if (!$parentExists) { + return false; + } + $tmpFile = \OC::$server->getTempManager()->getTemporaryFile($ext); $handle = fopen($tmpFile, $mode); return CallbackWrapper::wrap($handle, null, null, function () use ($path, $tmpFile) { @@ -469,6 +478,9 @@ class ObjectStoreStorage extends \OC\Files\Storage\Common implements IChunkedFil public function file_put_contents($path, $data) { $handle = $this->fopen($path, 'w+'); + if (!$handle) { + return false; + } $result = fwrite($handle, $data); fclose($handle); return $result; |