Skip to content

Commit

Permalink
SymlinkManager: Various small but important fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
taminob committed Nov 23, 2023
1 parent a55bd0b commit c17656c
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions lib/private/Files/SymlinkManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public function __construct() {
* @return bool
*/
public function isSymlink($node) {
return $this->getId($node) === false;
return $this->getId($node) !== false;
}

/**
Expand All @@ -64,9 +64,9 @@ public function isSymlink($node) {
*/
public function storeSymlink($node) {
if ($this->isSymlink($node)) {
$this->insertSymlink($node);
} else {
$this->updateSymlink($node);
} else {
$this->insertSymlink($node);
}
}

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

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

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

/**
Expand Down

0 comments on commit c17656c

Please sign in to comment.