Server: occ files:scan elapsed time not good after 1 day

Created on 30 Jan 2019  路  6Comments  路  Source: nextcloud/server

NOT urgent

Steps to reproduce

  1. Scan a lots of files during more than 24H with
    occ files:scan --all

Expected behaviour

+---------+--------+--------------+
| Folders | Files | Elapsed time |
+---------+--------+--------------+
| 41936 | 454712 | 24:58:34 |
+---------+--------+--------------+

Actual behaviour

It tells me it took only 58 minutes. But it tooks more than one day. I suspect it ran 24:58:34

+---------+--------+--------------+
| Folders | Files | Elapsed time |
+---------+--------+--------------+
| 41936 | 454712 | 00:58:34 |
+---------+--------+--------------+

Server configuration

Operating system:
Centos 7

Web server:
Apache 2.4.6

Database:
MariaDB 10.0.37

PHP version:
PHP 7.2.14

Nextcloud version: (see Nextcloud admin page)
Nextcloud 15.0.2

Updated from an older Nextcloud/ownCloud or fresh install:
Fresh install

Where did you install Nextcloud from:
Nextcloud.com

3. to review bug good first issue

All 6 comments

Hi,
I just reviewed the code in apps/files/lib/Command/Scan.php.

The execution time is made by the difference between microTime at the beginning and microTime at the end and formatted using return date('H:i:s', $secs); line 295
So basically, the information that it was more than 24 hours already exists but the output is not able to handle that.

I see three possible fix:

  1. Hot fix: change the format to something like 'd:H:i:s'. It is really silly, and if it is really useful for someone, it can be done on the installation directly.
  2. Easy fix: add a function to handle when the number of hours are greater than 24h to handle this particular case. It is not so common
  3. Nice way: use a real time comparaison function as PHP provide it.

Regards

Hi, can we do something like this?
Since $this->execTime contains total elapsed time in seconds, we can just format it as

$t = round($this->execTime);
return sprintf('%02d:%02d:%02d', ($t/3600),($t/60%60), $t%60);

in
https://github.com/nextcloud/server/blob/0b7b938a60ad9a04712278bc5b8e543f07204200/apps/files/lib/Command/Scan.php#L291-L297

Would this be sufficient?

Reference : https://stackoverflow.com/a/3534705

I didn't test that but looks good :+1:

Can I work on this issue ?

I have created a pull request #14342 to fix this issue. Kindly let me know if any changes are required.

Was this page helpful?
0 / 5 - 0 ratings