I wanted to make this thread to aggregate a few different resources that I found useful to help debug my permissions issue - I couldn’t find any prior art online.
TLDR
Make sure that everything inside your nextcloud data directories is owned by www/data
and not anything else.
Background
Using iOS Nextcloud app, I went to change my auto-upload from just new photos to the entire camera roll. Upon doing this, I received an error along the lines of Error creating subfolders
.
Weirdly some of the files seemed to come through fine, but others seemed stuck and when I attempted to delete the directories in the UI, it said the operations failed. I couldn’t upload or create a directory inside those directories created in the latest auto-upload.
I also noticed that a lot of the directories were in the Pending
state which struck me as odd.
Solving
- The Pending state seemed to be a red herring as only the new files were in a pending state.
- Deleting the directories using
occ
How to delete a file or folder with OCC 🤔 - this didn’t work. Even though the CLI made it look like everything was deleted successfully, it didn’t actually succeed. - Looking at the logs in the Administration Settings, I noticed I was getting errors like Forbidden Sabre\DAV\Exception\Forbidden error. While this was a good lead, I didn’t follow the steps in that thread because the error was occurring only on a subset of my uploads, not all of them.
- I then stumbled upon [SOLVED] Can't delete permanently: "Permission denied" which made me look at the permissions of the data files which ultimately led to the solution.
Solution
Open up a shell in your nextcloud container/host and make sure that www/data
owns the correct directories/files. I found somehow that they were owned by root
and I had to chown them so Nextcloud could read/write the appropriate files. I followed Change ownership of Nextcloud files (root to www-data) - #2 by KarlF12 but needed to escape the exec command by adding a \
at the end, for example:
find nextcloud/ -type d -exec chmod 750 {} \;