Bareos Bug Tracker - bareos-core
View Issue Details
0000973bareos-core[All Projects] webuipublic2018-06-28 11:192018-08-08 13:09
will care
0000973: WEBUI Restore Too Many Files error caused by bad JSON [issue present at least from 17.2.4]
I solved this issue on my 17.2.4 install but when I looked at the code in the master, I saw that this issues was "fixed". However, the "fix" in the master is not good and will also cause bad JSON to be uploaded to the webui causing the "too many files" error box.
For the current master branch:
- go to the restore ui
- try to open a directory without subdirectories.

For the 17.2.4 version:
- go to the restore UI
- try to open a directory containing one directory and multiple files.

For the current master, the issue is on line 361 of /master/webui/module/Restore/src/Restore/Controller/RestoreController.php

[ [^]]

This line is now:
if($fnum > 0) {

This does not take into account the case when there are no subdirs in this subtree and will add a stray comma before the files json elements, causing an error in the browser.

Changing this line to
if( $tmp > 0 && $fnum > 0 ) {

solves the problem. ($tmp is set to $dnum and holds the number of directories in the subtree.


Additional info:

In the 17.2.4 branch, this line is actually different, but also wrong:
if( $tmp > 2 && $fnum > 0 ) {

The $tmp > 2 is wrong since directories with only 1 or 2 subdirs won't get the comma added and a JSON error complaining about that will result.
I suspect the current state of the file in master is a result of someone "fixing" this problem incorrectly.
No tags attached.
Issue History
2018-06-28 11:19jhonNew Issue
2018-08-07 14:01aron_sAssigned To => aron_s
2018-08-07 14:01aron_sStatusnew => assigned
2018-08-08 13:09aron_sbareos-master: impact => yes
2018-08-08 13:09aron_sbareos-master: action => will care
2018-08-08 13:09aron_sNote Added: 0003095
2018-08-08 13:09aron_sStatusassigned => resolved

2018-08-08 13:09   
Thank you for the report and the already fixed line.
I tested this and submitted a PR against our master branch.
Furthermore I'd like to encourage you to just open a pull request yourself the next time.
That case is likely to be handled much faster than opening a bug report here!