Server: Server replied : Locked ( I cannot modify a folder or file! )

Created on 23 Feb 2018  ·  8Comments  ·  Source: nextcloud/server

Sometimes I cannot modify some folder or file from my cloud.

Actual behaviour

For example I got these messages when I went to delete the "_Nextcloud Manual.pdf_" file :

Nextcloud Manual.pdf

Fatal   webdav  OCA\DAV\Connector\Sabre\Exception\FileLocked: "Nextcloud Manual.pdf" is locked

    /var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/Tree.php - line 179: OCA\DAV\Connector\Sabre\File->delete()
    /var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/CorePlugin.php - line 287: Sabre\DAV\Tree->delete('Nextcloud Manua...')
    [internal function] Sabre\DAV\CorePlugin->httpDelete(Object(Sabre\HTTP\Request), Object(Sabre\HTTP\Response))
    /var/www/nextcloud/3rdparty/sabre/event/lib/EventEmitterTrait.php - line 105: call_user_func_array(Array, Array)
    /var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php - line 479: Sabre\Event\EventEmitter->emit('method DELETE', Array)
    /var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php - line 254: Sabre\DAV\Server->invokeMethod(Object(Sabre\HTTP\Request), Object(Sabre\HTTP\Response))
    /var/www/nextcloud/apps/dav/appinfo/v1/webdav.php - line 80: Sabre\DAV\Server->exec()
    /var/www/nextcloud/remote.php - line 164: require_once('/var/www/nextcl...')
    {main}

2018-02-23T03:45:03+0200

Server configuration

Operating system:
Ubuntu Server 16.04.3 LTS

Web server:

Server version: Apache/2.4.18 (Ubuntu)
Server built:   2017-09-18T15:09:02

Database:
mysql Ver 15.1 Distrib 10.0.33-MariaDB, for debian-linux-gnu (x86_64) using readline 5.2

PHP version:

PHP 7.0.25-0ubuntu0.16.04.1 (cli) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies
    with Zend OPcache v7.0.25-0ubuntu0.16.04.1, Copyright (c) 1999-2017, by Zend Technologies

Nextcloud version: (see Nextcloud admin page)
Fresh install from Nextcloud 11. Now I'm in version 13!

Signing status:


Signing status

No errors have been found.



List of activated apps:


App list

Enabled:
  - activity: 2.6.1
  - admin_audit: 1.3.0
  - admin_notifications: 1.0.1
  - bruteforcesettings: 1.0.3
  - checksum: 0.3.5
  - comments: 1.3.0
  - dav: 1.4.6
  - deck: 0.3.0
  - federatedfilesharing: 1.3.1
  - federation: 1.3.0
  - files: 1.8.0
  - files_external: 1.4.1
  - files_markdown: 2.0.1
  - files_pdfviewer: 1.2.0
  - files_sharing: 1.5.0
  - files_texteditor: 2.5.1
  - files_trashbin: 1.3.0
  - files_versions: 1.6.0
  - files_videoplayer: 1.2.0
  - firstrunwizard: 2.2.1
  - gallery: 18.0.0
  - logreader: 2.0.0
  - lookup_server_connector: 1.1.0
  - nextcloud_announcements: 1.2.0
  - notifications: 2.1.2
  - oauth2: 1.1.0
  - password_policy: 1.3.0
  - provisioning_api: 1.3.0
  - quota_warning: 1.2.0
  - serverinfo: 1.3.0
  - sharebymail: 1.3.0
  - spreed: 3.1.0
  - survey_client: 1.1.0
  - systemtags: 1.3.0
  - theming: 1.4.1
  - twofactor_backupcodes: 1.2.3
  - updatenotification: 1.3.0
  - workflowengine: 1.3.0
Disabled:
  - encryption
  - user_external
  - user_ldap



Nextcloud configuration:


Config report

{
    "system": {
        "instanceid": "***REMOVED SENSITIVE VALUE***",
        "passwordsalt": "***REMOVED SENSITIVE VALUE***",
        "secret": "***REMOVED SENSITIVE VALUE***",
        "trusted_domains": [
            "mycloud.me"
        ],
        "datadirectory": "***REMOVED SENSITIVE VALUE***",
        "overwrite.cli.url": "https:\/\/mycloud.me",
        "dbtype": "mysql",
        "version": "13.0.0.14",
        "dbname": "***REMOVED SENSITIVE VALUE***",
        "dbhost": "***REMOVED SENSITIVE VALUE***",
        "dbport": "",
        "dbtableprefix": "oc_",
        "dbuser": "***REMOVED SENSITIVE VALUE***",
        "dbpassword": "***REMOVED SENSITIVE VALUE***",
        "logtimezone": "UTC",
        "installed": true,
        "mail_smtpmode": "smtp",
        "mail_domain": "***REMOVED SENSITIVE VALUE***",
        "mail_from_address": "***REMOVED SENSITIVE VALUE***",
        "mail_smtpsecure": "ssl",
        "mail_smtpauthtype": "LOGIN",
        "mail_smtpauth": 1,
        "mail_smtpname": "***REMOVED SENSITIVE VALUE***",
        "mail_smtppassword": "***REMOVED SENSITIVE VALUE***",
        "mail_smtphost": "***REMOVED SENSITIVE VALUE***",
        "mail_smtpport": "465",
        "memcache.local": "\\OC\\Memcache\\APCu",
        "maintenance": false,
        "theme": "",
        "loglevel": 2,
        "updater.secret": "***REMOVED SENSITIVE VALUE***"
    }

Are you using external storage, if yes which one:
Yes : /mnt/externalStorage/

Are you using encryption:
I think not.

Are you using an external user-backend, if yes which one:
I think not.

Client configuration

Browser:
Mozilla Firefox ESR 52.6.0
Chromium 64.0.3282.119

Operating system:
Debian GNU/Linux 9.3 (stretch).

Logs

Nextcloud log (data/nextcloud.log)


Nextcloud log

{"reqId":"3dFsymiobcAwLM95reGw","level":4,"time":"2018-02-20T09:24:02+00:00","remoteAddr":"91.138.149.166","user":"Tassos","app":"webdav","method":"DELETE","url":"\/remote.php\/webdav\/Nextcloud%20Manual.pdf","message":"Exception: {\"Exception\":\"OCA\\\\DAV\\\\Connector\\\\Sabre\\\\Exception\\\\FileLocked\",\"Message\":\"\\\"Nextcloud Manual.pdf\\\" is locked\",\"Code\":0,\"Trace\":\"#0 \\\/var\\\/www\\\/nextcloud\\\/3rdparty\\\/sabre\\\/dav\\\/lib\\\/DAV\\\/Tree.php(179): OCA\\\\DAV\\\\Connector\\\\Sabre\\\\File->delete()\\n#1 \\\/var\\\/www\\\/nextcloud\\\/3rdparty\\\/sabre\\\/dav\\\/lib\\\/DAV\\\/CorePlugin.php(287): Sabre\\\\DAV\\\\Tree->delete('Nextcloud Manua...')\\n#2 [internal function]: Sabre\\\\DAV\\\\CorePlugin->httpDelete(Object(Sabre\\\\HTTP\\\\Request), Object(Sabre\\\\HTTP\\\\Response))\\n#3 \\\/var\\\/www\\\/nextcloud\\\/3rdparty\\\/sabre\\\/event\\\/lib\\\/EventEmitterTrait.php(105): call_user_func_array(Array, Array)\\n#4 \\\/var\\\/www\\\/nextcloud\\\/3rdparty\\\/sabre\\\/dav\\\/lib\\\/DAV\\\/Server.php(479): Sabre\\\\Event\\\\EventEmitter->emit('method:DELETE', Array)\\n#5 \\\/var\\\/www\\\/nextcloud\\\/3rdparty\\\/sabre\\\/dav\\\/lib\\\/DAV\\\/Server.php(254): Sabre\\\\DAV\\\\Server->invokeMethod(Object(Sabre\\\\HTTP\\\\Request), Object(Sabre\\\\HTTP\\\\Response))\\n#6 \\\/var\\\/www\\\/nextcloud\\\/apps\\\/dav\\\/appinfo\\\/v1\\\/webdav.php(80): Sabre\\\\DAV\\\\Server->exec()\\n#7 \\\/var\\\/www\\\/nextcloud\\\/remote.php(164): require_once('\\\/var\\\/www\\\/nextcl...')\\n#8 {main}\",\"File\":\"\\\/var\\\/www\\\/nextcloud\\\/apps\\\/dav\\\/lib\\\/Connector\\\/Sabre\\\/File.php\",\"Line\":375}","userAgent":"Mozilla\/5.0 (X11; Linux x86_64; rv:52.0) Gecko\/20100101 Firefox\/52.0","version":"13.0.0.14"}

{"reqId":"0j8Ukfllh8lmtUrFILPm","level":4,"time":"2018-02-20T09:24:14+00:00","remoteAddr":"91.138.149.166","user":"Tassos","app":"webdav","method":"DELETE","url":"\/remote.php\/webdav\/Nextcloud%20Manual.pdf","message":"Exception: {\"Exception\":\"OCA\\\\DAV\\\\Connector\\\\Sabre\\\\Exception\\\\FileLocked\",\"Message\":\"\\\"Nextcloud Manual.pdf\\\" is locked\",\"Code\":0,\"Trace\":\"#0 \\\/var\\\/www\\\/nextcloud\\\/3rdparty\\\/sabre\\\/dav\\\/lib\\\/DAV\\\/Tree.php(179): OCA\\\\DAV\\\\Connector\\\\Sabre\\\\File->delete()\\n#1 \\\/var\\\/www\\\/nextcloud\\\/3rdparty\\\/sabre\\\/dav\\\/lib\\\/DAV\\\/CorePlugin.php(287): Sabre\\\\DAV\\\\Tree->delete('Nextcloud Manua...')\\n#2 [internal function]: Sabre\\\\DAV\\\\CorePlugin->httpDelete(Object(Sabre\\\\HTTP\\\\Request), Object(Sabre\\\\HTTP\\\\Response))\\n#3 \\\/var\\\/www\\\/nextcloud\\\/3rdparty\\\/sabre\\\/event\\\/lib\\\/EventEmitterTrait.php(105): call_user_func_array(Array, Array)\\n#4 \\\/var\\\/www\\\/nextcloud\\\/3rdparty\\\/sabre\\\/dav\\\/lib\\\/DAV\\\/Server.php(479): Sabre\\\\Event\\\\EventEmitter->emit('method:DELETE', Array)\\n#5 \\\/var\\\/www\\\/nextcloud\\\/3rdparty\\\/sabre\\\/dav\\\/lib\\\/DAV\\\/Server.php(254): Sabre\\\\DAV\\\\Server->invokeMethod(Object(Sabre\\\\HTTP\\\\Request), Object(Sabre\\\\HTTP\\\\Response))\\n#6 \\\/var\\\/www\\\/nextcloud\\\/apps\\\/dav\\\/appinfo\\\/v1\\\/webdav.php(80): Sabre\\\\DAV\\\\Server->exec()\\n#7 \\\/var\\\/www\\\/nextcloud\\\/remote.php(164): require_once('\\\/var\\\/www\\\/nextcl...')\\n#8 {main}\",\"File\":\"\\\/var\\\/www\\\/nextcloud\\\/apps\\\/dav\\\/lib\\\/Connector\\\/Sabre\\\/File.php\",\"Line\":375}","userAgent":"Mozilla\/5.0 (X11; Linux x86_64; rv:52.0) Gecko\/20100101 Firefox\/52.0","version":"13.0.0.14"}

When I went to delete the same file from my computer, the client program displays this error :
Nextcloud client error

I can't even rename these files!
What happening ? What can I do to solve this problem ?

I have run the command :
sudo -u www-data php console.php files:scan --all
but failed to fix the problem. :(

Τhank you!

Most helpful comment

Add the following entry in the config.php file of your nextcloud

'filelocking.enabled' => false,

done so you can delete the file or locked files

remove option if you do not need it anymore

All 8 comments

1: ls -la from data directory to check files rules and ownership
should be like www-data:www-data with 755 for directory and 644 for files.

2: check your apache2 config for access right to directories + access to files.

3: verify your htaccess

1.

/mnt/path_to/nextcloud/data# ls -alh
σύνολο 272M
drwxrwx--- 16 www-data www-data 4,0K Φεβ  21 13:24 .
drwxr-xr-x  3 root     root     4,0K Ιαν  29  2017 ..
drwxr-xr-x 10 www-data www-data 4,0K Νοέ  12 18:32 appdata_octl4upace2y
drwxr-xr-x  2 www-data www-data 4,0K Φεβ  20 09:56 files_external
-rw-r--r--  1 www-data www-data  324 Φεβ  20 09:55 .htaccess
-rw-r--r--  1 www-data www-data    0 Φεβ  20 09:55 index.html
drwxr-xr-x  4 www-data www-data 4,0K Μάρ  23  2017 user_admin
drwxr-xr-x  5 www-data www-data 4,0K Μάρ  24  2017 user1
drwxr-xr-x  5 www-data www-data 4,0K Ιαν   4 12:50 user2
drwxr-xr-x  6 www-data www-data 4,0K Ιούλ 20  2017 user3
drwxr-xr-x  6 www-data www-data 4,0K Μάι   2  2017 user4
drwxr-xr-x  3 www-data www-data 4,0K Μάρ  23  2017 user5
drwxr-xr-x  6 www-data www-data 4,0K Οκτ   1 22:00 user6
drwxr-xr-x  5 www-data www-data 4,0K Μάρ  23  2017 user8
drwxr-xr-x  4 www-data www-data 4,0K Φεβ   2  2017 user9
drwxr-xr-x  6 www-data www-data 4,0K Φεβ  21 17:42 user10
drwxr-xr-x  8 www-data www-data 4,0K Φεβ  21 12:05 user11
-rw-r--r--  1 www-data www-data 269M Φεβ  23 10:07 nextcloud.log
-rw-r--r--  1 www-data www-data    0 Φεβ  20 09:55 .ocdata
-rw-r--r--  1 www-data www-data 2,0M Φεβ  20 09:54 updater.log
drwxr-xr-x  4 www-data www-data 4,0K Φεβ  20 09:56 updater-octl4upace2y
/mnt/path_to/nextcloud/data# ls -alh user1/
σύνολο 76K
drwxr-xr-x    8 www-data www-data 4,0K Φεβ  21 12:05 .
drwxrwx---   16 www-data www-data 4,0K Φεβ  21 13:24 ..
drwxr-xr-x    2 www-data www-data 4,0K Μάι  19  2017 cache
drwxr-xr-x   10 www-data www-data 4,0K Φεβ  21 16:42 files
drwxr-xr-x    5 www-data www-data 4,0K Φεβ  21 16:39 files_trashbin
drwxr-xr-x    5 www-data www-data  16K Ιαν  14 12:59 files_versions
drwxr-xr-x 1140 www-data www-data  36K Νοέ  11 18:57 thumbnails
drwxr-xr-x    2 www-data www-data 4,0K Φεβ  21 00:35 uploads
/mnt/path_to/nextcloud/data# ls -alh user1/files
σύνολο 4,1M
drwxr-xr-x 10 www-data www-data 4,0K Φεβ  21 16:42 .
drwxr-xr-x  8 www-data www-data 4,0K Φεβ  21 12:05 ..
drwxr-xr-x  8 www-data www-data 4,0K Ιαν  21 17:50 Documents
drwxr-xr-x  4 www-data www-data  16K Ιαν   4 12:56 Music
-rw-r--r--  1 www-data www-data 4,0M Ιαν  29  2017 Nextcloud Manual.pdf
drwxr-xr-x  2 www-data www-data 4,0K Ιαν  14 12:33 Photos
drwxr-xr-x 10 www-data www-data 4,0K Φεβ  21 00:28 My Shared folders
drwxr-xr-x  2 www-data www-data 4,0K Ιαν  14 12:38 Videos
  1. What do you mean?
    In most files I have correct access, only in very few files or folders I have the problem that I mention to you. In most files or folders I have correct access (_I have no problem)_.

  2. How ?

Thank you very much!

Add the following entry in the config.php file of your nextcloud

'filelocking.enabled' => false,

done so you can delete the file or locked files

remove option if you do not need it anymore

Thank you very very much! This trick has solved my problem! :smile:

After I deleted the files, I also removed the above setting from the configuration file.
But what exactly is happening with this setting do?
Why were my files locked?

Thank you very much for the immediate response!

your files were blocked because most likely some other user or admin was going to download them or they had not downloaded or they were badly shared, that's why they get stuck to prevent someone else having problems sharing or downloading anyway with this entry you forced deletion and you did well.

you can close the problem if you want now.

@tigernero79 I'm not able to find the term filelocking in any config.php file. I have installed NextCloud via snap. So I used this command to search:

find / -type f -iname "config.php" 2>&1 | egrep -v "Permission denied|No such file or directory" | xargs grep "filelocking"

but I get:

grep: /var/snap/nextcloud/8273/nextcloud/config/config.php: Permission denied
grep: /var/snap/nextcloud/8970/nextcloud/config/config.php: Permission denied

@Foadsf you can edit the config in the snap version via:
sudo vi /var/snap/nextcloud/current/nextcloud/config/config.php

edit your configuration file config/config.php:
'filelocking.enabled' => false,

Then stop and start your Nextcloud instance
sudo snap disable nextcloud
sudo snap enable nextcloud

Just do not forget to revert your change to filelocking afterwards ...

Was this page helpful?
0 / 5 - 0 ratings