How to fix Nextcloud client getting stuck : tutorial

Using the Linux client, if you keep on getting sync errors and client being stuck for no reason, here is my workaround :

  • in the root directory of your Nextcloud server, create a blank php file called cleaning.php (you can name it whatever you want)

  • open this file with a basic text editor, and write the following :

echo "<br><br>CLEANING ALL LOCK FILES...";
$aVar = mysqli_connect($bdd_serveur,$bdd_login,$bdd_mdp,$bdd);
$query1 = mysqli_query($aVar, "DELETE FROM `".$bdd."`.`oc_file_locks` WHERE `oc_file_locks`.`lock` != 0") or die('Erreur SQL !<br>'.$sql.'<br>'.mysqli_error());
echo "<br>Cleaning done without errors";