vault

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2024 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultConfigString = `` /* 1477-byte string literal not displayed */

)

Variables

This section is empty.

Functions

func CompareFiles

func CompareFiles(source, target string) (bool, error)

CompareFiles compares the content of two files using a hash. It returns true if the files are identical and false otherwise. It returns an error if the source file is a directory or if there is an error reading the files.

func FilterIgnore

func FilterIgnore(
	paths []string,
	ignorePatterns []string,
	progressCb func(int64),
) []string

func IsConfigExists

func IsConfigExists(path string) (bool, error)

func ListFilesRel

func ListFilesRel(log func(string, ...any), root string, progressCb func(int64), skipPermissionDenied bool) ([]string, error)

ListFilesRel walks the file system starting from the root and returns a list of relative file paths.

func PathWithoutExtension

func PathWithoutExtension(path string) string

func ProcessFiles added in v0.0.5

func ProcessFiles(
	template string,
	et *exiftool.Exiftool,
	sourceDir, targetDir string,
	files []FileWithSidecars,
	action func(source, target string, isPrimary bool) error,
) error

func RenderTemplate

func RenderTemplate(templateStr string, fields any) (string, error)

func TransferFile added in v0.0.5

func TransferFile(
	log func(string, ...any),
	source, target string,
	dryRun, verify, move bool,
) (actionTaken bool, err error)

TransferFile copies a file from source to target path, with safety checks. It will: - Skip if source and target are identical - Error if source/target is a directory - Skip if target exists with identical content - Remove and replace target if content differs

dryRun simulates operations without making changes verify returns errors instead of executing if any action is required move indicates whether to move instead of copy

func WriteDefaultConfigToFile

func WriteDefaultConfigToFile(path string) error

Types

type Config

type Config struct {
	Template             string   `yaml:"template" json:"template"`
	SkipPermissionDenied bool     `yaml:"skipPermissionDenied" json:"skipPermissionDenied"`
	Ignore               []string `yaml:"ignore" json:"ignore"`
	SidecarExtensions    []string `yaml:"sidecarExtensions" json:"sidecarExtensions"`
}

func DefaultConfig

func DefaultConfig() *Config

func ReadConfigFromFile

func ReadConfigFromFile(path string) (*Config, error)

func ReadConfigFromString

func ReadConfigFromString(content string) (*Config, error)

func (*Config) JSON

func (c *Config) JSON() (string, error)

func (*Config) Validate

func (c *Config) Validate() error

type ExifMetadata

type ExifMetadata map[string]interface{}

func ExtractExifMetadata

func ExtractExifMetadata(
	et *exiftool.Exiftool,
	file string,
) (ExifMetadata, error)

type FileWithSidecars

type FileWithSidecars struct {
	Path     string
	Sidecars []string
}

func LinkSidecars

func LinkSidecars(
	sidecarExtensions []string,
	files []string,
) []FileWithSidecars

type FsMetadata

type FsMetadata struct {
	Path string
	Base string
	Ext  string
	Name string
	Dir  string
}

func ExtractFsMetadata

func ExtractFsMetadata(
	file string,
) FsMetadata

type HashMetadata

type HashMetadata struct {
	Md5  string
	Sha1 string

	Md5Short  string
	Sha1Short string
}

func ExtractHashMetadata

func ExtractHashMetadata(
	file string,
) (HashMetadata, error)

type Metadata

type Metadata struct {
	Fs   FsMetadata
	Exif ExifMetadata
	Hash HashMetadata
}

func ExtractMetadata

func ExtractMetadata(
	et *exiftool.Exiftool,
	base string,
	path string,
) (Metadata, error)

Jump to

Keyboard shortcuts

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