nextcloud / files_zip

Allow zipping files directly on your NC server
GNU Affero General Public License v3.0
20 stars 3 forks source link

Error while Zipping when root folder is read only: `No create permission for path` #39

Open szaimen opened 2 years ago

szaimen commented 2 years ago

Just tried the app and I got the following issue:

{
  "reqId": "ddnrK6weTbpLI0qMPo7o",
  "level": 3,
  "time": "2021-11-19T00:55:02+01:00",
  "remoteAddr": "",
  "user": "--",
  "app": "files_zip",
  "method": "",
  "url": "--",
  "message": "Failed to create zip archive",
  "userAgent": "--",
  "version": "22.2.3.0",
  "exception": {
    "Exception": "OCP\\Files\\NotPermittedException",
    "Message": "No create permission for path",
    "Code": 0,
    "Trace": [
      {
        "file": "/var/www/nextcloud/apps/files_zip/lib/Service/ZipService.php",
        "line": 92,
        "function": "newFile",
        "class": "OC\\Files\\Node\\Folder",
        "type": "->"
      },
      {
        "file": "/var/www/nextcloud/apps/files_zip/lib/BackgroundJob/ZipJob.php",
        "line": 65,
        "function": "zip",
        "class": "OCA\\FilesZip\\Service\\ZipService",
        "type": "->"
      },
      {
        "file": "/var/www/nextcloud/lib/public/BackgroundJob/Job.php",
        "line": 79,
        "function": "run",
        "class": "OCA\\FilesZip\\BackgroundJob\\ZipJob",
        "type": "->"
      },
      {
        "file": "/var/www/nextcloud/lib/public/BackgroundJob/QueuedJob.php",
        "line": 47,
        "function": "execute",
        "class": "OCP\\BackgroundJob\\Job",
        "type": "->"
      },
      {
        "file": "/var/www/nextcloud/cron.php",
        "line": 127,
        "function": "execute",
        "class": "OCP\\BackgroundJob\\QueuedJob",
        "type": "->"
      }
    ],
    "File": "/var/www/nextcloud/lib/private/Files/Node/Folder.php",
    "Line": 209,
    "CustomMessage": "Failed to create zip archive"
  },
  "id": "6196e81a535c6"
}

It has most likely the same reason why https://github.com/nextcloud/server/issues/25787 happened.

juliusknorr commented 2 years ago

From the PR:

The thing is that I have actually create permissions in the folder I was trying to create the zip archive in. But the root folder itself is read only on my instance which probably triggered the issue although it should work in the directory I am in... (see nextcloud/server#25787 where something like this happened to)

joshtrichards commented 1 year ago

Seems to have been poked at a bit more here:

https://github.com/nextcloud/server/pull/26396

And here:

https://github.com/nextcloud/cms_pico/pull/167

Which seems like a whole it of redundant and extra work just because newFile checks the root/base.

This would seem a clean solution:

https://github.com/nextcloud/server/pull/26396#issuecomment-822231348

I don't think any changes like this were made but I'll have to return to this later when I have more time:

https://github.com/nextcloud/server/blob/6e41ebcc126a846d3de0c737e62f673a0e4f1b49/lib/private/Files/Node/Folder.php#L179