"Sabre\DAV\Exception: Could not rename part file to final file" Problem

Support intro

Sorry to hear you’re facing problems :slightly_frowning_face:

help.nextcloud.com is for home/non-enterprise users. If you’re running a business, paid support can be accessed via portal.nextcloud.com where we can ensure your business keeps running smoothly.

In order to help you as quickly as possible, before clicking Create Topic please provide as much of the below as you can. Feel free to use a pastebin service for logs, otherwise either indent short log examples with four spaces:

example

Or for longer, use three backticks above and below the code snippet:

longer
example
here

Some or all of the below information will be requested if it isn’t supplied; for fastest response please provide as much as you can :heart:

Nextcloud version (eg, 20.0.5): Nextcloud Hub 5 (27.0.0)
Operating system and version (eg, Ubuntu 20.04): Ubuntu 22.04.2 LTS
Apache or nginx version (eg, Apache 2.4.25): Apache 2.4.52
PHP version (eg, 7.4): 8.1

The issue you are facing:
I created a folder named test in /var/www/html/nextcloud/admin/files with root permission and set its permission to 755. Then I created another folder called test2 in folder test, set test2’s permission to 777. Theoretically anyone could create, upload and delete files in folder test2, I thought.
Then I logged in NC as admin. Everything was fine. There was no issue when I was testing the folder test2. After that I shared the folder to another user called testuser , granting him full permission.
I logged in as testuser and found that I could create, delete and rename files or folders just as I thought previously. However, when I tried to upload some files in test2, I was told “Could not rename part file to final file”.
I did not encounter with the same issue when I logged in as admin. I do not know why.
Is there any difference in the upload process?
It is REALLY WEIRD…

Is this the first time you’ve seen this error? (Y/N): Y

Steps to replicate it:

  1. Create a folder with root permission and set it to 755.
  2. Create another folder in previous folder and set the new folder to 777.
  3. Share the folder in step 1 to anyone else in NC with full permission(). And the bug appears. The user being shared with can do anything in the 777 folder including creating new files EXCEPT uploading files. If you create a sharing link with full permission, there will be no problem when you attempting to upload files.
    Make sure to use www-data to run NC.

The output of your Nextcloud log in Admin > Logging:

[webdav] Error: Sabre\DAV\Exception: Could not rename part file to final file at <<closure>>

0. /var/www/html/nextcloud/apps/dav/lib/Connector/Sabre/Directory.php line 149
   OCA\DAV\Connector\Sabre\File->put()
1. /var/www/html/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php line 1098
   OCA\DAV\Connector\Sabre\Directory->createFile("*** sensitive parameters replaced ***")
2. /var/www/html/nextcloud/3rdparty/sabre/dav/lib/DAV/CorePlugin.php line 504
   Sabre\DAV\Server->createFile("*** sensitive parameters replaced ***")
3. /var/www/html/nextcloud/3rdparty/sabre/event/lib/WildcardEmitterTrait.php line 89
   Sabre\DAV\CorePlugin->httpPut()
4. /var/www/html/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php line 472
   Sabre\DAV\Server->emit()
5. /var/www/html/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php line 253
   Sabre\DAV\Server->invokeMethod()
6. /var/www/html/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php line 321
   Sabre\DAV\Server->start()
7. /var/www/html/nextcloud/apps/dav/appinfo/v1/webdav.php line 85
   Sabre\DAV\Server->exec()
8. /var/www/html/nextcloud/remote.php line 172
   require_once("/var/www/html/n ... p")

The output of your config.php file in /path/to/nextcloud (make sure you remove any identifiable information!):

<?php
$CONFIG = array (
  'instanceid' => 'oco2vjrqy6nb',
  'passwordsalt' => 'J1A0qP4lDwnp2gz3f+D2wJnBgCE8Ug',
  'secret' => 'g+LhI4/ypfc9atUcAva1hK3UUsKnSLdMKdklw4YruTCOPKtZ',
  'trusted_domains' =>
  array (
    0 => '192.168.235.128',
  ),
  'datadirectory' => '/var/www/html/nextcloud/data',
  'dbtype' => 'mysql',
  'version' => '27.0.0.8',
  'overwrite.cli.url' => 'http://192.168.235.128/nextcloud',
  'dbname' => 'nextcloud',
  'dbhost' => 'localhost',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'mysql.utf8mb4' => true,
  'dbuser' => 'oc_admin',
  'dbpassword' => 'M*5Fl-:U5!T-(<kr1kQ3?a;|TNq-@#',
  'installed' => true,
  'allow_local_remote_servers' => true,
  'filesystem_check_changes' => true,
  'ldapProviderFactory' => 'OCA\\User_LDAP\\LDAPProviderFactory',
);

The output of your Apache/nginx/system log in /var/log/____:

192.168.235.1 - - [04/Jul/2023:02:58:32 +0000] "GET /nextcloud/index.php/apps/recommendations/api/recommendations HTTP/1.1" 200 1085 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36 Edg/114.0.1823.67"
192.168.235.1 - - [04/Jul/2023:02:58:32 +0000] "PROPFIND /nextcloud/remote.php/dav/files/admin/ HTTP/1.1" 207 1538 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36 Edg/114.0.1823.67"
192.168.235.1 - - [04/Jul/2023:02:58:33 +0000] "GET /nextcloud/ocs/v2.php/apps/notifications/api/v2/notifications HTTP/1.1" 200 1250 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36 Edg/114.0.1823.67"
192.168.235.1 - - [04/Jul/2023:02:58:33 +0000] "GET /nextcloud/index.php/apps/files/ajax/getstoragestats?dir=%2F HTTP/1.1" 200 12858 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36 Edg/114.0.1823.67"
192.168.235.1 - - [04/Jul/2023:02:58:35 +0000] "PUT /nextcloud/ocs/v2.php/apps/user_status/api/v1/heartbeat?format=json HTTP/1.1" 200 951 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36"
192.168.235.1 - - [04/Jul/2023:02:58:41 +0000] "PUT /nextcloud/remote.php/webdav/test/test2/%E8%A1%A5%E5%85%85N.txt HTTP/1.1" 500 771 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36"
192.168.235.1 - - [04/Jul/2023:02:58:28 +0000] "GET /nextcloud/index.php/apps/logreader/poll?lastReqId=HgewWxQUml60tKRaBsHY HTTP/1.1" 200 1625 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36 Edg/114.0.1823.67"
::1 - - [04/Jul/2023:02:58:41 +0000] "OPTIONS * HTTP/1.0" 200 126 "-" "Apache/2.4.52 (Ubuntu) (internal dummy connection)"

Hi @Application -

The files on the underlying filesystem all need to be owned by the user that your Nextcloud instance runs as on your system. That’s going to be www-data.

You don’t normally need to worry about this though since all files should be getting uploaded/downloaded through Nextcloud’s Web interface or an appropriately authenticated client application/WebDAV client (with some exceptions like for External Storage but that’s an advanced topic).

So before getting into the nitty gritty of what went wrong let’s back up a bit.

What problem are you trying to solve? Put another way, why are you logging in and creating files directly in your underlying filesystem and - in essence - bypassing Nextcloud? :slight_smile: You may have a legitimate reason for doing so - that’s fine - but unless you describe it to us we’ll probably giving you inappropriate advice. :slight_smile:

tldr:

  • Files must be owned by www-data (in your case since you’re using Ubuntu)
  • If you add files outside of (i.e. by bypassing) Nextcloud special things need to be done like running scan jobs (see the Admin Manual)

Thanks for your reply.
Here’s the reason: I want to make a public sharing folder that everyone can freely visit, edit and remove files in. However, the sharing folder has its own structure like dept1, dept2, dept3 in its root directory, and what I expect is that everyone can change the files in dept1, dept2 or dept3 instead of the root directory, thus I want to change the root directory’s owner to root so that the root directory is read-only.
Do you have better ideas? Thanks!

Is there someone who has an idea? :grinning: