The popular problem…
I recently went into trouble with an OwnCloud installation on one of our servers. A few users had problems accessing any files or even upload new ones with errors like “404 not found” or “Forbidden”…
It figured out, that these problems must be connected to the move of the datastore-folder some time ago. It seems that only useraccounts that have been created before moving the folder were affected by the problem.
Non-working fix attempts
The OwnCloud FAQ recommends to run the “occ”-util with “files:scan –all –repair”. This did not fix anything, nor did any other maintenance-tasks of the occ-tool fix the error. Reading the other users’ comments pointed out that I was not alone with it.
Also the common advise to (re-)set the owner and file-permissions recursivly on the datastore-folder did not do the trick – as expected – as they already were in a mint condition.
If the problem can not be fixed on file-level, it must be somewhere in the database. So I connected to the database via commandline-client and digged through the tables of OwnCloud looking for something that looks like a wrong filepath or something.
The real fix (at least for me)
To make it short: It’s the table “oc_accounts” that still holds the wrong file pathes after moving the datastore. So all we have to do now is to list all entries that do NOT match the new file path scheme. Let’s assume the correct file path is ‘/var/www/html/owncloud/data’. In that case the query would be:
select * from oc_accounts where home not like '%/var/www/html/owncloud/data/%';
This will output all entries that have wrong file pathes. We need the columns “id” and “home” from there. With these values we can update the entries with the corrent path. Make sure that you only change the common part of the path, not the user’s folder:
update oc_accounts set home = '/var/www/html/owncloud/data/testuser' where id = 123;
Repeat with all affected users. This should instantly fix the issue, no need to restart OC and/or the database.