Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Do not emit preHooks twice on non-part-storage
The old code would emit the hooks twice. Thus having the version written
twice. Which is not very performant as it is first read twice as well.

Signed-off-by: Roeland Jago Douma <[email protected]>
  • Loading branch information
rullzer committed Oct 21, 2018
commit 998b646f97e8e9402dacc83cdf323cf9ab44c55d
11 changes: 5 additions & 6 deletions apps/dav/lib/Connector/Sabre/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,28 +138,27 @@ public function put($data) {
list($partStorage) = $this->fileView->resolvePath($this->path);
$needsPartFile = $this->needsPartFile($partStorage) && (strlen($this->path) > 1);

$view = \OC\Files\Filesystem::getView();

if ($needsPartFile) {
// mark file as partial while uploading (ignored by the scanner)
$partFilePath = $this->getPartFileBasePath($this->path) . '.ocTransferId' . rand() . '.part';
} else {
// upload file directly as the final path
$partFilePath = $this->path;

$this->emitPreHooks($exists);
if ($view && !$this->emitPreHooks($exists)) {
throw new Exception('Could not write to final file, canceled by hook');
}
}

$view = \OC\Files\Filesystem::getView();

// the part file and target file might be on a different storage in case of a single file storage (e.g. single file share)
/** @var \OC\Files\Storage\Storage $partStorage */
list($partStorage, $internalPartPath) = $this->fileView->resolvePath($partFilePath);
/** @var \OC\Files\Storage\Storage $storage */
list($storage, $internalPath) = $this->fileView->resolvePath($this->path);
try {
if (!$needsPartFile) {
if ($view && !$this->emitPreHooks($exists)) {
throw new Exception('Could not write to final file, canceled by hook');
}
$this->changeLock(ILockingProvider::LOCK_EXCLUSIVE);
}

Expand Down