Skip to content

Commit c17656c

Browse files
committed
SymlinkManager: Various small but important fixes
1 parent a55bd0b commit c17656c

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

lib/private/Files/SymlinkManager.php

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public function __construct() {
5454
* @return bool
5555
*/
5656
public function isSymlink($node) {
57-
return $this->getId($node) === false;
57+
return $this->getId($node) !== false;
5858
}
5959

6060
/**
@@ -64,9 +64,9 @@ public function isSymlink($node) {
6464
*/
6565
public function storeSymlink($node) {
6666
if ($this->isSymlink($node)) {
67-
$this->insertSymlink($node);
68-
} else {
6967
$this->updateSymlink($node);
68+
} else {
69+
$this->insertSymlink($node);
7070
}
7171
}
7272

@@ -97,7 +97,7 @@ public function purgeSymlink($path = '/') {
9797
$query = $this->connection->getQueryBuilder();
9898
$query->select('*')
9999
->from(self::TABLE_NAME)
100-
->where($query->expr()->like('storage', $query->createNamedParameter($this->connection->escapeLikeParameter($path) . '/%')));
100+
->where($query->expr()->like('path', $query->createNamedParameter($this->connection->escapeLikeParameter($path) . '/%')));
101101
$result = $query->executeQuery();
102102

103103
while ($row = $result->fetch()) {
@@ -147,6 +147,9 @@ private function updateSymlink($node) {
147147
->set('storage', $query->createNamedParameter($storageId))
148148
->set('path', $query->createNamedParameter($path))
149149
->set('last_updated', $query->createNamedParameter($lastUpdated));
150+
if ($query->executeStatement() != 1) {
151+
throw new \OCP\DB\Exception("Invalid number of rows changed while updating symlink!");
152+
}
150153
}
151154

152155
/**
@@ -164,6 +167,9 @@ private function insertSymlink($node) {
164167
->setValue('storage', $query->createNamedParameter($storageId))
165168
->setValue('path', $query->createNamedParameter($path))
166169
->setValue('last_updated', $query->createNamedParameter($lastUpdated));
170+
if ($query->executeStatement() != 1) {
171+
throw new \OCP\DB\Exception("Invalid number of rows changed while inserting symlink!");
172+
}
167173
}
168174

169175
/**

0 commit comments

Comments
 (0)