Skip to content

Commit

Permalink
don't always check if we need to setup the object store root
Browse files Browse the repository at this point in the history
Signed-off-by: Robin Appelman <[email protected]>
  • Loading branch information
icewind1991 authored and juliushaertl committed Jun 6, 2023
1 parent 8d24c61 commit 9f7be63
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion lib/private/Files/ObjectStore/ObjectStoreStorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public function __construct($params) {
$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)) {
Expand Down Expand Up @@ -230,6 +230,13 @@ public function stat($path) {
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;
}
}
Expand Down Expand Up @@ -331,6 +338,12 @@ public function fopen($path, $mode) {
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) {
Expand Down Expand Up @@ -443,6 +456,9 @@ public function needsPartFile() {

public function file_put_contents($path, $data) {
$handle = $this->fopen($path, 'w+');
if (!$handle) {
return false;
}
$result = fwrite($handle, $data);
fclose($handle);
return $result;
Expand Down

0 comments on commit 9f7be63

Please sign in to comment.