Data corrupted after RAID was slow

I’m running Nextcloud 13.0.4.0 (with PHP 7.0.33) on my Raspberry Pi. I changed my RAID. Due to this, access to the RAID was very slow while mdadm was busy reshaping it. Nextcloud had a problem with this and syncing didn’t work properly anymore. Now mdadm is done, the RAID is back to its usual speed, but I can’t get Nextcloud to sync.

When I add new files via the desktop client, it says in the activity tab:

Server replied "500 Internal Server Errror" to "PUT https://mydomain.com/nextcloud/path/to/file.extension

(Yes, there is no closing quote in the end.)

I tried uploading a file via the web interface. It resulted in this error message:

An exception occurred while executing 'INSERT INTO "oc_filecache" ("mimepart","mimetype","mtime","size","etag","storage_mtime","permissions","parent","checksum","path_hash","path","name","storage") SELECT ?,?,?,?,?,?,?,?,?,?,?,?,? WHERE NOT EXISTS (SELECT 1 FROM "oc_filecache" WHERE "storage" = ? AND "path_hash" = ?)' with params ["10", "11", 1552765170, 9, "50f2129e7072daae80c51a0a301a0d32", 1552765170, 27, 21855, "", "59cc43281000a7c3d4bc78cde990025c", "files\/Documents\/someFile.txt", "someFile.txt", 4, 4, "59cc43281000a7c3d4bc78cde990025c"]: SQLSTATE[HY000]: General error: 11 database disk image is malformed

The admin log also contains many error messages:

|Error|PHP|file_put_contents(/media/raid/nextcloud/data/appdata_ocyh4dwg8ajx/js/core/merged-template-prepend.js.deps): failed to open stream: Structure needs cleaning at /var/www/html/nextcloud/lib/private/Files/Storage/Local.php#218|2019-03-16T21:00:31+0100|
|---|---|---|---|
|Error|PHP|file_put_contents(/media/raid/nextcloud/data/appdata_ocyh4dwg8ajx/js/core/merged-template-prepend.js): failed to open stream: Structure needs cleaning at /var/www/html/nextcloud/lib/private/Files/Storage/Local.php#218|2019-03-16T21:00:31+0100|
|Error|PHP|filesize(): stat failed for /media/raid/nextcloud/data/appdata_ocyh4dwg8ajx/js/core/merged-template-prepend.js.deps at /var/www/html/nextcloud/lib/private/LargeFileHelper.php#171|2019-03-16T21:00:31+0100|
|Error|PHP|stat(): stat failed for /media/raid/nextcloud/data/appdata_ocyh4dwg8ajx/js/core/merged-template-prepend.js.deps at /var/www/html/nextcloud/lib/private/Files/Storage/Local.php#140|2019-03-16T21:00:31+0100|
|Error|PHP|file_get_contents(/media/raid/nextcloud/data/appdata_ocyh4dwg8ajx/js/core/merged-template-prepend.js.deps): failed to open stream: Structure needs cleaning at /var/www/html/nextcloud/lib/private/Files/Storage/Local.php#214|2019-03-16T21:00:31+0100|
|Error|PHP|file_put_contents(/media/raid/nextcloud/data/appdata_ocyh4dwg8ajx/js/core/merged-template-prepend.js.deps): failed to open stream: Structure needs cleaning at /var/www/html/nextcloud/lib/private/Files/Storage/Local.php#218|2019-03-16T21:00:26+0100|
|Error|PHP|file_put_contents(/media/raid/nextcloud/data/appdata_ocyh4dwg8ajx/js/core/merged-template-prepend.js): failed to open stream: Structure needs cleaning at /var/www/html/nextcloud/lib/private/Files/Storage/Local.php#218|2019-03-16T21:00:26+0100|
|Error|PHP|filesize(): stat failed for /media/raid/nextcloud/data/appdata_ocyh4dwg8ajx/js/core/merged-template-prepend.js.deps at /var/www/html/nextcloud/lib/private/LargeFileHelper.php#171|2019-03-16T21:00:26+0100|
|Error|PHP|stat(): stat failed for /media/raid/nextcloud/data/appdata_ocyh4dwg8ajx/js/core/merged-template-prepend.js.deps at /var/www/html/nextcloud/lib/private/Files/Storage/Local.php#140|2019-03-16T21:00:26+0100|
|Error|PHP|file_get_contents(/media/raid/nextcloud/data/appdata_ocyh4dwg8ajx/js/core/merged-template-prepend.js.deps): failed to open stream: Structure needs cleaning at /var/www/html/nextcloud/lib/private/Files/Storage/Local.php#214|2019-03-16T21:00:26+0100|
|Error|PHP|file_put_contents(/media/raid/nextcloud/data/appdata_ocyh4dwg8ajx/js/core/merged-template-prepend.js.deps): failed to open stream: Structure needs cleaning at /var/www/html/nextcloud/lib/private/Files/Storage/Local.php#218|2019-03-16T21:00:16+0100|
|Error|PHP|file_put_contents(/media/raid/nextcloud/data/appdata_ocyh4dwg8ajx/js/core/merged-template-prepend.js): failed to open stream: Structure needs cleaning at /var/www/html/nextcloud/lib/private/Files/Storage/Local.php#218|2019-03-16T21:00:16+0100|
|Error|PHP|filesize(): stat failed for /media/raid/nextcloud/data/appdata_ocyh4dwg8ajx/js/core/merged-template-prepend.js.deps at /var/www/html/nextcloud/lib/private/LargeFileHelper.php#171|2019-03-16T21:00:16+0100|
|Error|PHP|stat(): stat failed for /media/raid/nextcloud/data/appdata_ocyh4dwg8ajx/js/core/merged-template-prepend.js.deps at /var/www/html/nextcloud/lib/private/Files/Storage/Local.php#140|2019-03-16T21:00:16+0100|
|Error|PHP|file_get_contents(/media/raid/nextcloud/data/appdata_ocyh4dwg8ajx/js/core/merged-template-prepend.js.deps): failed to open stream: Structure needs cleaning at /var/www/html/nextcloud/lib/private/Files/Storage/Local.php#214|2019-03-16T21:00:16+0100|
|Error|PHP|file_put_contents(/media/raid/nextcloud/data/appdata_ocyh4dwg8ajx/js/core/merged-template-prepend.js.deps): failed to open stream: Structure needs cleaning at /var/www/html/nextcloud/lib/private/Files/Storage/Local.php#218|2019-03-16T21:00:12+0100|

What’s wrong with the SQLite database? Is there a way to recover from this?