Skip to content

Commit 6582b78

Browse files
committed
SymlinkManager: Use numeric_id for storage in database
Signed-off-by: Tamino Bauknecht <dev@tb6.eu>
1 parent 911ea13 commit 6582b78

1 file changed

Lines changed: 20 additions & 1 deletion

File tree

lib/private/Files/SymlinkManager.php

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,16 +186,35 @@ private function deleteSymlinkById($id) {
186186

187187
/**
188188
* @param \OCP\Files\FileInfo $node
189+
*
190+
* @return string
189191
*/
190192
private function getNameFromNode($node) {
191193
return $node->getName();
192194
}
193195

194196
/**
195197
* @param \OCP\Files\FileInfo $node
198+
*
199+
* @return int
196200
*/
197201
private function getStorageIdFromNode($node) {
198-
return $node->getStorage()->getId();
202+
$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!");
216+
}
217+
return $numericId;
199218
}
200219

201220
/**

0 commit comments

Comments
 (0)