Deleted Folder Still Present

Nextcloud version: 11.0.1
Operating system and version: Ubuntu 16.10.1
Apache or nginx version: Apache 2.4.18
PHP version: 7.0.13
Is this the first time you’ve seen this error and can you replicate it?: Yes and Yes.

Problem:
I just setup Nextcloud, and have been toying with it for a couple days. When I first set it up, I had created a folder that I then deleted. I then perminantly deleted it from the Deleted Files. However, I went back to my Files, and low and behold, the folder is still there. I try to open it, but it doesn’t open. I try to delete it, and it goes away, but if I refresh the Files screen, it comes back. I have two accounts setup right now, and the problem exists with both accounts. Right now, there are absolutely no files in either account, no other folders, and nothing in the Delete Files. However, when I run occ files:scan, it still returns results…


Log:

I’d upload the log, but I have a ton of the following entries, multiples every second. I’m not sure what that’s about, but it could be because my primary web server is Server 2012r2, and I have a URL rewrite to direct my NextCloud folder on my .com to my Ubuntu server. If anyone knows, please advise. I’d like to fix that too so I can actually read the log.

Error PHP preg_match(): Unknown modifier ‘/’ at /var/www/html/drive/lib/private/AppFramework/Http/Request.php#622


Config:

<?php
$CONFIG = array (
  'instanceid' => 'xxxxxxxx',
  'passwordsalt' => 'xxxxxxxx',
  'secret' => 'xxxxxxxx',
  'trusted_domains' => 
  array (
    0 => 'xxxxxxxx.com',
    1 => 'www.xxxxxxxx.com',
    2 => '10.0.0.23',
  ),
  'overwritecondaddr' => 'http://xxxxxxxx.com',
  'overwritehost' => 'xxxxxxxx.com',
  'datadirectory' => '/var/www/html/drive/data',
  'overwrite.cli.url' => 'http://xxxxxxxx.com/drive',
  'dbtype' => 'mysql',
  'version' => '11.0.1.2',
  'dbname' => 'xxxxxxxx',
  'dbhost' => 'localhost',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'dbuser' => 'xxxxxxxx',
  'dbpassword' => 'xxxxxxxx',
  'logtimezone' => 'UTC',
  'installed' => true,
  'mail_from_address' => 'mike',
  'mail_smtpmode' => 'php',
  'mail_domain' => 'xxxxxxxx.com',
  'loglevel' => 0,
);

Please check the permissions of the folder on the filesystem of the webserver. It looks like NC deletes the folder in the database, and also tries to delete it on the drive - which fails - but the error is never reported back to you or to nextcloud. If the permissions are wrong then nextcloud can’t do anything about it.

Is it just this one folder or are other folders also a problem?

Cu

I just created and deleted a new folder, and it’s permanently gone. It doesn’t look like it’s reappeared. When you say check the permissions, you mean of the nextcloud data folder?

Thanks,
Mike

Hi,

yes inside the data folder on the disk. The structure follows this scheme:

nextcloud/data/$username/files/ <- this is the root folder that you see in the web ui. From there the subfolders should be the same as in your web ui. Check the permissions on the particular folder that can’t be deleted. It should be the owner and group that the webserver runs under, e.g. www-data and www-data and have the permissions of at least 700 or better 750 or 770. If that’s not the case then NC can’t delete the folder.

Cu

Linux is still a bit foreign to me, so forgive my ignorance.

I tried checking permissions of the files directory, but there was nothing there.

eptesicus@7xDRIVE:~$ sudo ls -l /var/www/html/drive/data/$eptesicus/files
ls: cannot access '/var/www/html/drive/data//files': No such file or directory

eptesicus@7xDRIVE:~$ sudo ls -l /var/www/html/drive/data/$admin/files
ls: cannot access '/var/www/html/drive/data//files': No such file or directory

I went back one to check permissions for both users, and found the following. Am I missing something here?

eptesicus@7xDRIVE:~$ sudo ls -l /var/www/html/drive/data/$eptesicus/
total 2688
drwxr-xr-x 7 www-data www-data    4096 Feb 10 21:15 admin
drwxr-xr-x 6 www-data www-data    4096 Feb  8 18:12 appdata_ocy7z36k2eg4
drwxr-xr-x 7 www-data www-data    4096 Feb 10 21:19 eptesicus
drwxr-xr-x 2 www-data www-data    4096 Feb  8 18:11 files_external
-rw-r--r-- 1 www-data www-data       0 Feb  8 18:10 index.html
-rw-r----- 1 www-data www-data 2514905 Feb 10 21:28 nextcloud.log
-rw-r--r-- 1 www-data www-data  208514 Feb  8 18:14 themedbackgroundlogo
-rw-r--r-- 1 www-data www-data    5218 Feb  8 18:17 themedinstancelogo

eptesicus@7xDRIVE:~$ sudo ls -l /var/www/html/drive/data/$admin
total 2692
drwxr-xr-x 7 www-data www-data    4096 Feb 10 21:15 admin
drwxr-xr-x 6 www-data www-data    4096 Feb  8 18:12 appdata_ocy7z36k2eg4
drwxr-xr-x 7 www-data www-data    4096 Feb 10 21:19 eptesicus
drwxr-xr-x 2 www-data www-data    4096 Feb  8 18:11 files_external
-rw-r--r-- 1 www-data www-data       0 Feb  8 18:10 index.html
-rw-r----- 1 www-data www-data 2516756 Feb 10 21:29 nextcloud.log
-rw-r--r-- 1 www-data www-data  208514 Feb  8 18:14 themedbackgroundlogo
-rw-r--r-- 1 www-data www-data    5218 Feb  8 18:17 themedinstancelogo

Ah, I see my mistake. Here’s what you were asking for…

eptesicus@7xDRIVE:~$ sudo ls -l /var/www/html/drive/data/admin/files
total 4
drwxr-xr-x 2 www-data www-data 4096 Feb  9 08:42 Music

That Music folder is the one that should be permanently deleted.

The same issue exists for the ‘eptesicus’ user.

Hi,

hahaha, ok fast explanation.

$username is a variable. Actually it’s the same in PHP (language that NC is written in) and in BASH (the shell you’re using). It’s often used in examples or texts like these to tell you “put your username here”.

So instead of ls -al /var/www/html/drive/data/$eptesicus/ just use ls -al /var/www/html/drive/data/eptesicus/

Else BASH evaluates $username which is empty and you’re screwed…

Another option would be to cd to the directory and then do an ls -al there.

Files are always only 6,4 or 0. ONLY IF - AND ONLY THEN - you want to execute a file (e.g. a script) inside your shell or use a shebang at the top to execute it with a different interpreter will the “1” be added which marks the file executable. “occ” in nextcloud’s root should be executable.

The values btw. are 1,2 and 4 meaning for files:

4 - Read
2 - Write
1 - Execute

and for folders:
4 - Read
2 - Write
1 - Allowed to change into the folder and list it

Those values are added the way they needed and then give you the number you need. For read (4) and write (2) it gives you a 6.

Then you can set the permissions for the owner of the file, the group the file belongs to and the rest of the world. Which gives you those numbers you see very often like 750 or 666.

Example: Let’s say you want to allow the owner of the file read/write, the group read and all others no access. That gives you:

Owner: Read (4) + Write (2) -> 6
Group: Read(4) -> 4
Rest: Nothing(0) -> 0

And this turns into: 640

So to change the permissions one would use chmod 640 /some/file

For directories a common value is 750. So everything for the owner, group can read and change into it and the rest of the world is out of luck.

Cu

Hm the folder looks fine to me. But you can delete it manually and run a rescan of the files and folders and see what happens.

Cu

Thanks for the explanation, Cu. I appreciate it!

I found the Music folder that shouldn’t be there. I went ahead and deleted the folder, thinking that it might get removed from nextcloud. Although the actual folder is now deleted, it still appears in nextcloud and the issue persists.

I recreated the folder, giving it the appropriate permissions, but the issue persists. What’s next?

Rescan? Should I do that with occ?

Hi,

yeah remove the folder from the filesystem and then either delete it in nextcloud too or just run occ files:scan

cu

Perfect!!! Thanks, Cu. It looks like doing that fixed the issue!

you’re welcome.