User Tools

Site Tools


docs:tips_n_tricks:nextcloud.html

Nextcloud

Troubleshooting locks

Logging locks

config.php.patch
--- config.php.orig    2025/01/11 11:02:10
+++ config.php    2025/01/11 11:02:11
@@ -29,3 +29,4 @@
   'log_type' => 'file',
   'logtimezone' => 'UTC',
+  'filelocking.debug' => true,
 );

Find files and expiry

~$ echo -n 'home::peter::files/Documents/About.txt' | md5sum | awk '{print "files/"$1}'
files/64b3e23bb2d4bf9c284dee81de153a65
~$ cd /var/lib/nextcloud/data/ # your data dir might be somewhere else ...
~$ sqlite3 --cmd '.header on' owncloud.db 'SELECT ttl FROM oc_file_locks WHERE KEY="files/64b3e23bb2d4bf9c284dee81de153a65";'
636892|-1|files/64b3e23bb2d4bf9c284dee81de153a65|1736598723
~$ date -d @`sqlite3 owncloud.db 'SELECT ttl FROM oc_file_locks WHERE KEY="files/64b3e23bb2d4bf9c284dee81de153a65";'`
Sat Jan 11 12:53:01 UTC 2025
~$ sqlite3 --cmd '.separator \t \n' --cmd '.headers on' owncloud.db 'SELECT id,lock,strftime("%Y-%m-%d %H:%M:%S",ttl,"unixepoch","localtime") AS Timestamp,key FROM oc_file_locks WHERE lock > 0 AND ttl >= strftime("%s","now") ORDER BY ttl ASC LIMIT 20;'
id      lock    Timestamp       key
594786  2       2025-01-12 01:42:20     files/724420cd1df913fa109950d75ff86a8c
594787  2       2025-01-12 01:42:20     files/db90de96feaf1431aec0e175272915bd
594788  2       2025-01-12 01:42:21     files/7215d0b2b3918163e38c04db929c616f
633606  2       2025-01-12 01:42:21     files/3c5cfd54ca1b9aa52ddf53e519c6ecaa
633607  2       2025-01-12 01:42:21     files/8b4d19c8fad691dd9fb4aac377a79b32
629846  2       2025-01-12 01:54:06     files/08608388ab9388d0ff8f929e37083787
594771  29      2025-01-12 01:55:02     files/14f3becba9007876dd5cc797f174739c
594816  7       2025-01-12 01:55:03     files/b4e69986ee606ca892ad3645ba7a6f28
594817  3       2025-01-12 01:55:03     files/d5869ca367cf034080f6138c76f6466f
594818  5       2025-01-12 01:55:04     files/58eaf399656f0b7b5fe81da63c149e79
594819  5       2025-01-12 01:55:04     files/ada037dbc4c386f1adb2c24bd13cc4c5
mk_file_key_list.sh
#!/bin/bash
max="`sqlite3 owncloud.db 'SELECT count(*) FROM oc_filecache;'`"
sqlite3 owncloud.db 'SELECT stor.id||"::"||fcache.path 
                       FROM oc_filecache AS fcache
                        JOIN oc_storages AS stor
                          ON fcache.storage = stor.numeric_id ;' \
| while read line
  do
     printf '%s : %s\n' \
            "`echo -n \"$line\" | md5sum | awk '{print \"files/\"$1}'`" \
            "$line"
  done \
| pv -l -s "${max}" > /tmp/file_key_list.txt

Delete outdated locks (cleanup)

~$ cd /var/lib/nextcloud/data/ # your data dir might be somewhere else ...

Delete all locks, that are expired now:

~$ sqlite3 --cmd '.separator \t \n' --cmd '.headers on' owncloud.db \
           'DELETE FROM oc_file_locks WHERE lock > 0 AND ttl <= strftime("%s","now") ORDER BY ttl ASC LIMIT 20;'

Delete all locks, that are expired at midnight on December 31th 2024 in your local time2):

~$ sqlite3 --cmd '.separator \t \n' --cmd '.headers on' owncloud.db \
           'DELETE FROM oc_file_locks WHERE lock > 0 AND ttl <= strftime("%s","2025-01-01 00:00:00","UTC") ;'

Delete all locks, that are expired five minutes ago3):

~$ sqlite3 --cmd '.separator \t \n' --cmd '.headers on' owncloud.db \
           'DELETE FROM oc_file_locks WHERE lock > 0 AND ttl <= strftime("%s","'"`date -d '-5min' +'%Y-%m-%d %H:%M:%S'`"'","UTC") ;'

Tagged pages (tag plugin)

Indexed pages (subjectindex plugin)

NextcloudNextcloud

1)
Just in case, Nextcloud deletes the original while conducting their plans to clean up the forum
2) , 3)
sqlite3 seems to weirdly take a timezone counterintuitive into account when formatting %s - which should be the same value in all timezones in my opinion as it is by definition in UTC. So, if any timezone is taken into account, it should be the timezone of the timestamp given before. However, to get the real EPOCH timestammp, you need to request timezone UTC here
docs/tips_n_tricks/nextcloud.html.txt · Last modified: 04.07.2025 02:18 CEST by peter

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki