PiwigoDirectoryUploader/internal/pkg/localFileStructure/imageList.go

36 lines
756 B
Go
Raw Normal View History

package localFileStructure
import (
"github.com/sirupsen/logrus"
2019-02-27 23:26:18 +01:00
"path/filepath"
"time"
)
func GetImageList(fileSystem map[string]*FilesystemNode) ([]*ImageNode, error) {
2019-02-27 23:26:18 +01:00
imageFiles := make([]*ImageNode, 0, len(fileSystem))
for _, file := range fileSystem {
if file.IsDir {
continue
}
md5sum, err := calculateFileCheckSums(file.Path)
if err != nil {
return nil, err
}
2019-02-27 23:26:18 +01:00
logrus.Debugf("Local Image %s - %s - %s", md5sum, file.ModTime.Format(time.RFC3339), file.Path)
imageFiles = append(imageFiles, &ImageNode{
2019-02-27 23:26:18 +01:00
Path: file.Path,
Directory: filepath.Dir(file.Path),
ModTime: file.ModTime,
Md5Sum: md5sum,
})
}
2019-02-27 23:26:18 +01:00
logrus.Infof("Found %d local images to process", len(imageFiles))
return imageFiles, nil
}