filesorter

package
v0.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 7, 2025 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetS3Client

func GetS3Client(s S3Config) (*s3.S3, error)

func GetS3ObjectData

func GetS3ObjectData(s S3Config, s3client *s3.S3, path string) ([]byte, error)

func MoveURL

func MoveURL(u string, s3configFile path.Local, fl *FileWithProperties, testonly bool) error

TODO implement

func PutS3ObjectData

func PutS3ObjectData(checksumsha256 string, s S3Config, s3client *s3.S3, path string, bt []byte) error

func Run

func Run(configFile path.Local, s3configFile path.Local, isTest bool) error

Types

type Config

type Config struct {
	Sources []string

	Rules []Rule
}

type FileProp

type FileProp string
const (
	Name     FileProp = "name"
	NameSolo FileProp = "name_solo"
	Ext      FileProp = "ext"
	MinSize  FileProp = "minsize"
	MaxSize  FileProp = "maxsize"
	MimeType FileProp = "mime-type"
	Date     FileProp = "date"
	Drive    FileProp = "drive"
	Path     FileProp = "path"
	Dir      FileProp = "dir"
	All      FileProp = "all"
	Prop     FileProp = "property"
)

func (FileProp) String

func (p FileProp) String() string

type FileWithProperties

type FileWithProperties struct {
	Name       string
	Date       time.Time
	Path       path.Local
	Size       int
	Drive      string
	MimeType   string
	Properties map[string]string
}

func (FileWithProperties) TargetURL

func (f FileWithProperties) TargetURL(c Config) string

TargetURL will be empty, if there is not matching rule

type FilesWithProperties

type FilesWithProperties []*FileWithProperties

func FindFiles

func FindFiles(dir path.Local) (FilesWithProperties, error)

type Matcher

type Matcher struct {
	Property Property
	Pattern  string // regexp
}

func (Matcher) Matches

func (m Matcher) Matches(f FileWithProperties) bool

type Matchers

type Matchers []Matcher

func (Matchers) Matches

func (m Matchers) Matches(f FileWithProperties) bool

type Property

type Property struct {
	Prop FileProp
	Val  any
}

type Rule

type Rule struct {
	Matchers   Matchers
	URLPattern string
}

func (Rule) Matches

func (r Rule) Matches(f FileWithProperties) bool

type S3Config

type S3Config struct {
	Endpoint     string
	Region       string
	Key          string
	Secret       string
	Bucket       string
	SubPath      string
	ClientRegion string
}

type S3HostsConfigs

type S3HostsConfigs struct {
	Configs map[string]S3Config // keys can be pseudo-hosts; they only must match the host in the target url
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL