Fix handling of empty directories to not return null

This commit is contained in:
Dane Everitt 2019-05-01 22:08:54 -07:00
parent 3de40ddf98
commit c3515454f2
No known key found for this signature in database
GPG Key ID: EEA66103B3D71F53

View File

@ -274,9 +274,13 @@ func (fs *Filesystem) ListDirectory(p string) ([]*Stat, error) {
return nil, err return nil, err
} }
var out []*Stat
var wg sync.WaitGroup var wg sync.WaitGroup
// You must initialize the output of this directory as a non-nil value otherwise
// when it is marshaled into a JSON object you'll just get 'null' back, which will
// break the panel badly.
out := make([]*Stat, 0)
// Iterate over all of the files and directories returned and perform an async process // Iterate over all of the files and directories returned and perform an async process
// to get the mime-type for them all. // to get the mime-type for them all.
for _, file := range files { for _, file := range files {