OwnSql: Distinguish no-data from error #6677
authorChristian Kamm <mail@ckamm.de>
Mon, 4 Mar 2019 12:58:38 +0000 (13:58 +0100)
committerKevin Ottens <kevin.ottens@nextcloud.com>
Tue, 15 Dec 2020 09:58:43 +0000 (10:58 +0100)
commit4bd062f5befc15ea7cdea79ab871a11c6866698d
treed1dbf023258c59a0b178f5e02b9a41c98aea7d22
parentee6a48b3dc088b2c4e1580e7b42196d922aa7d61
OwnSql: Distinguish no-data from error #6677

This could fix a problem where the client incorrectly decides to delete
local data.

Previously any sqlite3_step() return value that wasn't SQLITE_ROW would
be interpreted as "there's no more data here". Thus an sqlite error at a
bad time could cause the remote discovery to fail to read an unchanged
subtree from the database. These files would then be deleted locally.

With this change sqlite errors from sqlite3_step are detected and
logged. For the particular case of SyncJournalDb::getFilesBelowPath()
the error will now be propagated and the sync run will fail instead of
performing spurious deletes.

Note that many other database functions still don't distinguish
not-found from error cases. Most of them won't have as severe effects on
affected sync runs though.
src/common/ownsql.cpp
src/common/ownsql.h
src/common/syncjournaldb.cpp
test/testownsql.cpp
test/testpermissions.cpp