Skip to content

Commit 0d600c5

Browse files
committed
SymlinkManager: Reduce code duplication for numeric_id and use internalPath
The user can already be identified using the storage id. Signed-off-by: Tamino Bauknecht <dev@tb6.eu>
1 parent 6582b78 commit 0d600c5

1 file changed

Lines changed: 5 additions & 15 deletions

File tree

lib/private/Files/SymlinkManager.php

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -200,27 +200,17 @@ private function getNameFromNode($node) {
200200
*/
201201
private function getStorageIdFromNode($node) {
202202
$storageId = $node->getStorage()->getId();
203-
$query = $this->connection->getQueryBuilder();
204-
$query->select('numeric_id')
205-
->from('storages')
206-
->where($query->expr()->eq('id', $query->createNamedParameter($storageId)));
207-
$result = $query->executeQuery();
208-
209-
if ($result->rowCount() > 1) {
210-
throw new \OCP\DB\Exception("Storage ('$storageId') is not unique in database!");
211-
}
212-
213-
$numericId = $result->fetchOne();
214-
if ($numericId === false) {
215-
throw new \OCP\DB\Exception("Unable to find storage '$storageId' in database!");
203+
if ($numericStorageId = \OC\Files\Cache\Storage::getNumericStorageId($storageId)) {
204+
return $numericStorageId;
205+
} else {
206+
throw new \OCP\Files\StorageNotAvailableException("Unable to find storage '$storageId'!");
216207
}
217-
return $numericId;
218208
}
219209

220210
/**
221211
* @param \OCP\Files\FileInfo $node
222212
*/
223213
private function getPathFromNode($node) {
224-
return $node->getPath();
214+
return $node->getInternalPath();
225215
}
226216
}

0 commit comments

Comments
 (0)