Error when copying or moving files with a size of zero bytes: Sabre\DAV\Exception: Error while copying file to target location (copied bytes: 0, expected filesize: -1 ) Nextcloud 16.0.4 Ubuntu 18.04.3

Support intro

Hi there,

When copying a large folder structure over the Nextcloud web interface, the copy process is aborted about 1 min after starting it so that the folder structure is only partially available at the target location.

Thanks for your support.

Best regards,
Peter

Nextcloud version: 16.0.4
Operating system and version: Ubuntu 18.04.3
Apache or nginx version: Apache/2.4.29 (Ubuntu)
PHP version: PHP 7.2.19-0ubuntu0.18.04.2

The issue you are facing:

Copying or moving large folder structures via the Nextcloud web interface is aborted after about one minute. Synchronizing folder structures via a Nextcloud client works fine for comparable sizes. So when copying a folder structure on a client and synchronizing such a folder structure works fine, but when performing the same action via the Nextcloud web interface, only a portion of the files is copied.

File locking is performed via Redis after having issues with file locking via the database. The Nextcloud log file does not show any database related errors. The Nextcloud performance suggestions have already been considered, as well as the config suggestions to handle large file sizes. The server has 32 GB memory.

Is this the first time you’ve seen this error?: NO

Steps to replicate it:

  1. Open Nextcloud web interface
  2. Select a large folder structure (I faced the problem with a folder structure of about 8.1GB size)
  3. Copy the selected folder structure to another place
  4. Wait for about one minute and encounter an error message " could not be copied"

The output of your Nextcloud log in Admin > Logging:

Fatal	webdav	Sabre\DAV\Exception: Error while copying file to target location (copied bytes: 0, expected filesize: -1 )

{"reqId":"8AFy1iaAcUI95PDmI1SZ","level":3,"time":"2019-09-02T11:17:56+00:00","remoteAddr":"<ipaddress-proxyserver>","user":"<nextcloud-user>","app":"no app in context","method":"COPY","url":"/remote.php/dav/files/<nextcloud-user>/<large-folder-to-copy>","message":{"Exception":"Sabre\\DAV\\Exception","Message":"Error while copying file to target location (copied bytes: 0, expected filesize: -1 )","Code":0,"Trace":[{"file":"/var/www/html/nextcloud/apps/dav/lib/Connector/Sabre/Directory.php","line":156,"function":"put","class":"OCA\\DAV\\Connector\\Sabre\\File","type":"->","args":[null]},{"file":"/var/www/html/nextcloud/3rdparty/sabre/dav/lib/DAV/Tree.php","line":316,"function":"createFile","class":"OCA\\DAV\\Connector\\Sabre\\Directory","type":"->","args":["28 Urlaubstage pro Jahr.txt",null]},{"file":"/var/www/html/nextcloud/3rdparty/sabre/dav/lib/DAV/Tree.php","line":326,"function":"copyNode","class":"Sabre\\DAV\\Tree","type":"->","args":[{"__class__":"OCA\\DAV\\Connector\\Sabre\\File"},{"__class__":"OCA\\DAV\\Connector\\Sabre\\Directory"}]},{"file":"/var/www/html/nextcloud/3rdparty/sabre/dav/lib/DAV/Tree.php","line":326,"function":"copyNode","class":"Sabre\\DAV\\Tree","type":"->","args":[{"__class__":"OCA\\DAV\\Connector\\Sabre\\Directory"},{"__class__":"OCA\\DAV\\Connector\\Sabre\\Directory"}]},{"file":"/var/www/html/nextcloud/3rdparty/sabre/dav/lib/DAV/Tree.php","line":326,"function":"copyNode","class":"Sabre\\DAV\\Tree","type":"->","args":[{"__class__":"OCA\\DAV\\Connector\\Sabre\\Directory"},{"__class__":"OCA\\DAV\\Connector\\Sabre\\Directory"}]},{"file":"/var/www/html/nextcloud/3rdparty/sabre/dav/lib/DAV/Tree.php","line":130,"function":"copyNode","class":"Sabre\\DAV\\Tree","type":"->","args":[{"__class__":"OCA\\DAV\\Connector\\Sabre\\Directory"},{"__class__":"OCA\\DAV\\Connector\\Sabre\\Directory"},"<large-folder-to-copy>"]},{"file":"/var/www/html/nextcloud/3rdparty/sabre/dav/lib/DAV/CorePlugin.php","line":684,"function":"copy","class":"Sabre\\DAV\\Tree","type":"->","args":["files/<nextcloud-user>/<large-folder-to-copy>","files/<nextcloud-user>/<nextcloud-user>/Archiv/<large-folder-to-copy>"]},{"function":"httpCopy","class":"Sabre\\DAV\\CorePlugin","type":"->","args":[{"absoluteUrl":"http://<hostaddress-proxyserver>/remote.php/dav/files/<nextcloud-user>/<large-folder-to-copy>","__class__":"Sabre\\HTTP\\Request"},{"__class__":"Sabre\\HTTP\\Response"}]},{"file":"/var/www/html/nextcloud/3rdparty/sabre/event/lib/EventEmitterTrait.php","line":105,"function":"call_user_func_array","args":[[{"__class__":"Sabre\\DAV\\CorePlugin"},"httpCopy"],[{"absoluteUrl":"http://<hostaddress-proxyserver>/remote.php/dav/files/<nextcloud-user>/<large-folder-to-copy>","__class__":"Sabre\\HTTP\\Request"},{"__class__":"Sabre\\HTTP\\Response"}]]},{"file":"/var/www/html/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php","line":479,"function":"emit","class":"Sabre\\Event\\EventEmitter","type":"->","args":["method:COPY",[{"absoluteUrl":"http://<hostaddress-proxyserver>/remote.php/dav/files/<nextcloud-user>/<large-folder-to-copy>","__class__":"Sabre\\HTTP\\Request"},{"__class__":"Sabre\\HTTP\\Response"}]]},{"file":"/var/www/html/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php","line":254,"function":"invokeMethod","class":"Sabre\\DAV\\Server","type":"->","args":[{"absoluteUrl":"http://<hostaddress-proxyserver>/remote.php/dav/files/<nextcloud-user>/<large-folder-to-copy>","__class__":"Sabre\\HTTP\\Request"},{"__class__":"Sabre\\HTTP\\Response"}]},{"file":"/var/www/html/nextcloud/apps/dav/lib/Server.php","line":316,"function":"exec","class":"Sabre\\DAV\\Server","type":"->","args":[]},{"file":"/var/www/html/nextcloud/apps/dav/appinfo/v2/remote.php","line":35,"function":"exec","class":"OCA\\DAV\\Server","type":"->","args":[]},{"file":"/var/www/html/nextcloud/remote.php","line":163,"args":["/var/www/html/nextcloud/apps/dav/appinfo/v2/remote.php"],"function":"require_once"}],"File":"/var/www/html/nextcloud/apps/dav/lib/Connector/Sabre/File.php","Line":218,"CustomMessage":"--"},"userAgent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:68.0) Gecko/20100101 Firefox/68.0","version":"16.0.4.1","id":"5d6cfa64b1588"}

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

<?php
$CONFIG = array (
  'instanceid' => '<hidden>',
  'passwordsalt' => '<hidden>',
  'secret' => '<hidden>',
  'trusted_domains' => 
  array (
    0 => '<hidden>',
    1 => '<hidden>',
    2 => '<hidden>',
    3 => '<hidden>',
    4 => '<hidden>',
  ),
  'trusted_proxies' => 
  array (
    0 => '<hidden>',
  ),
  'datadirectory' => '<hidden>',
  'dbtype' => 'mysql',
  'version' => '16.0.4.1',
  'overwrite.cli.url' => '<hidden>',
  'overwriteprotocol' => 'https',
  'dbname' => '<hidden>',
  'dbhost' => '<hidden>',
  'dbport' => '<hidden>',
  'dbtableprefix' => '<hidden>',
  'dbuser' => '<hidden>',
  'dbpassword' => '<hidden>',
  'installed' => true,
  'mail_smtpmode' => 'sendmail',
  'mail_smtpsecure' => 'tls',
  'mail_from_address' => '<hidden>',
  'mail_domain' => '<hidden>',
  'mail_smtpauthtype' => 'LOGIN',
  'mail_smtphost' => '<hidden>',
  'mail_smtpauth' => 1,
  'mail_smtpname' => '<hidden>',
  'mail_smtppassword' => '<hidden>',
  'memcache.local' => '\\OC\\Memcache\\APCu',
  'filelocking.enabled' => true,
  'memcache.locking' => '\\OC\\Memcache\\Redis',
  'redis' => 
  array (
    'host' => 'localhost',
    'port' => 6379,
    'timeout' => 0.0,
  ),
  'memcache.distributed' => '\\OC\\Memcache\\Memcached',
  'memcached_servers' => 
  array (
    0 => 
    array (
      0 => 'localhost',
      1 => 11211,
    ),
  ),
  'maintenance' => false,
  'ldapIgnoreNamingRules' => false,
  'ldapProviderFactory' => 'OCA\\User_LDAP\\LDAPProviderFactory',
  'theme' => '',
  'loglevel' => 2,
  'mysql.utf8mb4' => true,
  'data-fingerprint' => '<hidden>',
  'app_install_overwrite' => 
  array (
    0 => 'calendar',
    1 => 'mail',
    2 => 'spreed',
    3 => 'bookmarks_fulltextsearch',
  ),
  'mail_sendmailmode' => 'pipe',
);

No output in Apache error log at /var/log/apache2/nextcloud_error.log

It appears that the problem only occurs when the Sabre DAV transfers a file with a size of zero bytes. After modifying the file mentioned in the Nextcloud log, the copy process continued beyond this modified file.

However, I encounter other difficulties so that the copy process even does not work when changing all zero byte files to files containing one blank instead which will be discussed in a separate issue.

However, copying zero byte files via the Nextcloud web interface should work as it does when synchronizing it via a Nextcloud sync client.