A deprecated ioutil was replaced with os.ReadDir. And a bit mask compare was used instead of a symbol compare.
This commit is contained in:
parent
71e7765ba8
commit
a567a27c69
@ -1,7 +1,6 @@
|
|||||||
package files
|
package files
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"io/ioutil"
|
|
||||||
"net/url"
|
"net/url"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
@ -28,11 +27,16 @@ func ScanDirectory(path, urlBase string) (entries []DirEntry, stats DirStats, er
|
|||||||
var fileEntries []DirEntry = make([]DirEntry, 0)
|
var fileEntries []DirEntry = make([]DirEntry, 0)
|
||||||
var totalFilesSize int64 = 0
|
var totalFilesSize int64 = 0
|
||||||
|
|
||||||
dir, err := ioutil.ReadDir(path)
|
dir, err := os.ReadDir(path)
|
||||||
for _, entry := range dir {
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, ent := range dir {
|
||||||
|
entry, _ := ent.Info()
|
||||||
|
|
||||||
var isDirLink bool
|
var isDirLink bool
|
||||||
if entry.Mode().Type().String()[0] == 'L' {
|
if entry.Mode().Type()&os.ModeSymlink != 0 {
|
||||||
if slp, err := filepath.EvalSymlinks(filepath.Join(path, entry.Name())); err == nil {
|
if slp, err := filepath.EvalSymlinks(filepath.Join(path, entry.Name())); err == nil {
|
||||||
lStat, _ := os.Lstat(slp)
|
lStat, _ := os.Lstat(slp)
|
||||||
isDirLink = lStat.IsDir()
|
isDirLink = lStat.IsDir()
|
||||||
|
Loading…
Reference in New Issue
Block a user