Skip to content

Commit 0f41197

Browse files
committed
Use index to mark parent as outdated
Signed-off-by: Ari Selseng <ari@selseng.net>
1 parent 1b27e95 commit 0f41197

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

apps/files_external/lib/Command/Notify.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -161,14 +161,15 @@ private function markParentAsOutdated($mountId, $path, OutputInterface $output)
161161
$parent = '';
162162
}
163163

164+
$pathHash = md5(trim(\OC_Util::normalizeUnicode($parent), '/'));
164165
try {
165-
$this->updateQuery->execute([$parent, $mountId]);
166+
$this->updateQuery->execute([$mountId, $pathHash]);
166167
} catch (DriverException $ex) {
167168
$this->logger->logException($ex, ['app' => 'files_external', 'message' => 'Error while trying to mark folder as outdated', 'level' => ILogger::WARN]);
168169
$this->connection = $this->reconnectToDatabase($this->connection, $output);
169170
$output->writeln('<info>Needed to reconnect to the database</info>');
170171
$this->updateQuery = $this->getUpdateQuery($this->connection);
171-
$this->updateQuery->execute([$parent, $mountId]);
172+
$this->updateQuery->execute([$mountId, $pathHash]);
172173
}
173174
}
174175

@@ -205,8 +206,8 @@ private function getUpdateQuery(IDBConnection $connection) {
205206
// the query builder doesn't really like subqueries with parameters
206207
return $connection->prepare(
207208
'UPDATE *PREFIX*filecache SET size = -1
208-
WHERE `path` = ?
209-
AND `storage` IN (SELECT storage_id FROM *PREFIX*mounts WHERE mount_id = ?)'
209+
WHERE `storage` = (SELECT storage_id FROM *PREFIX*mounts WHERE mount_id = ?)
210+
AND `path_hash` = ?'
210211
);
211212
}
212213

0 commit comments

Comments
 (0)