Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: log absolute path for locked exception #50400

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions apps/dav/lib/Connector/Sabre/Directory.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,11 @@ public function createFile($name, $data = null) {

// only allow 1 process to upload a file at once but still allow reading the file while writing the part file
$node->acquireLock(ILockingProvider::LOCK_SHARED);
$this->fileView->lockFile($path . '.upload.part', ILockingProvider::LOCK_EXCLUSIVE);
$this->fileView->lockFile($node->getPath() . '.upload.part', ILockingProvider::LOCK_EXCLUSIVE);

$result = $node->put($data);

$this->fileView->unlockFile($path . '.upload.part', ILockingProvider::LOCK_EXCLUSIVE);
$this->fileView->unlockFile($node->getPath() . '.upload.part', ILockingProvider::LOCK_EXCLUSIVE);
$node->releaseLock(ILockingProvider::LOCK_SHARED);
return $result;
} catch (StorageNotAvailableException $e) {
Expand Down
2 changes: 1 addition & 1 deletion apps/dav/lib/Connector/Sabre/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ public function put($data) {
}
}
} catch (\Exception $e) {
if ($e instanceof LockedException) {
if ($e instanceof FileLocked) {
\OC::$server->get(LoggerInterface::class)->debug($e->getMessage(), ['exception' => $e]);
} else {
\OC::$server->get(LoggerInterface::class)->error($e->getMessage(), ['exception' => $e]);
Expand Down
34 changes: 17 additions & 17 deletions lib/private/Files/View.php
Original file line number Diff line number Diff line change
Expand Up @@ -2062,11 +2062,15 @@ private function lockPath($path, $type, $lockMountPoint = false) {
);
}
} catch (LockedException $e) {
// rethrow with the a human-readable path
$this->logger->debug($e->getMessage(), [
'exception' => $e,
'fakeRoot' => $this->fakeRoot,
'absolutePath' => $absolutePath,
]);
throw new LockedException(
$this->getPathRelativeToFiles($absolutePath),
$this->getRelativePath($absolutePath) ?? $e->getPath(),
$e,
$e->getExistingLock()
$e->getExistingLock(),
);
}

Expand Down Expand Up @@ -2102,20 +2106,16 @@ public function changeLock($path, $type, $lockMountPoint = false) {
);
}
} catch (LockedException $e) {
try {
// rethrow with the a human-readable path
throw new LockedException(
$this->getPathRelativeToFiles($absolutePath),
$e,
$e->getExistingLock()
);
} catch (\InvalidArgumentException $ex) {
throw new LockedException(
$absolutePath,
$ex,
$e->getExistingLock()
);
}
$this->logger->debug($e->getMessage(), [
'exception' => $e,
'fakeRoot' => $this->fakeRoot,
'absolutePath' => $absolutePath,
]);
throw new LockedException(
$this->getRelativePath($absolutePath) ?? $e->getPath(),
$e,
$e->getExistingLock(),
);
}

return true;
Expand Down
Loading