lib

package
v1.4.12 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2024 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NotCached   CacheStatus = false
	Cached      CacheStatus = true
	ExtEnabled  ExtState    = true
	ExtDisabled ExtState    = false
)

Variables

View Source
var (
	ErrNoImages = errors.New("no images found in directory")

	ErrHashPrefixTooShort = errors.New("hash prefix must be at least 3 characters")
	ErrHashInfoNil        = errors.New("hash info is nil; it must be initialized")
	ErrHashLengthTooShort = errors.New("hash length must be at least 10 characters")
)

Functions

func GetGoVersion

func GetGoVersion() string

func GetVersion

func GetVersion() string

GetVersion returns the application version set by the build process. If the binary is a dev build, then it returns a truncated version of the latest commit hash.

Types

type CacheStatus

type CacheStatus bool

type ExtState added in v1.4.12

type ExtState bool

type HashInfo

type HashInfo struct {
	// contains filtered or unexported fields
}

type HashResult

type HashResult struct {
	// contains filtered or unexported fields
}

type Hasher

type Hasher struct {
	// contains filtered or unexported fields
}

func NewHasher

func NewHasher(cfg HasherConfig) (*Hasher, error)

NewHasher creates a Hasher which takes a HasherConfig.

🟡 The HashConfig.Prefix should be a unique string, because it identifies which images have been renamed.

func (*Hasher) Hash

func (h *Hasher) Hash(
	fileName string,
	cs CacheStatus,
	filePath string,
	callBack func(cs CacheStatus),
)

func (*Hasher) Wait

func (h *Hasher) Wait()

type HasherConfig

type HasherConfig struct {
	// The smaller this is, the higher chance of collisions
	Length int
	// How many goroutines should be in pool
	Threads int
	// Queue channel minimum size
	QueueSize int
	// Container for hash results
	HashResult *HashResult
	// Should be a unique string
	Prefix     string
	BufferSize int64
}

type ImageExtMap

type ImageExtMap map[string]ExtState

type ImageMap

type ImageMap map[string]CacheStatus

func MapImages

func MapImages(dir, hashPrefix string) (ImageMap, error)

type ImageProcessor

type ImageProcessor struct {
	Status           *models.ProcessStatus
	WorkingDir       string
	HasDupes         bool
	OpenReviewFolder bool

	NovelDupePaths []string

	ProcessTime time.Duration
	// contains filtered or unexported fields
}

func NewImageProcessor

func NewImageProcessor(cfg ImageProcessorConfig) *ImageProcessor

func (*ImageProcessor) ProcessImages

func (ip *ImageProcessor) ProcessImages(useBuffer bool) error

ProcessImages calculates the hash of all images in the image map and separates out the duplicates from the new images.

func (*ImageProcessor) ProcessImagesForReview

func (ip *ImageProcessor) ProcessImagesForReview(useBuffer bool) error

ProcessImagesForReview processes the images, but also moves duplicate images to a temporary "dupe review folder," for the user to review. The folder is automatically opened after the dupes are moved.

func (*ImageProcessor) RestoreFromReview

func (ip *ImageProcessor) RestoreFromReview() error

RestoreFromReview restores all novel dupes back to the working directory, then deletes the dupe review folder and all its contents (the remaining dupes).

func (*ImageProcessor) UpdateImages

func (ip *ImageProcessor) UpdateImages() error

UpdateImages handles renaming and deleting images that have had their hashes processed. If the type of process was a "review", then it ONLY renames the images.

type ImageProcessorConfig

type ImageProcessorConfig struct {
	Prefix           string
	HashLength       int
	WorkingDir       string
	ImageMap         ImageMap
	DupeReviewFolder string
	OpenReviewFolder bool
}

type ProcessedImages

type ProcessedImages struct {
	NewImagesByHash  map[string]HashInfo
	DupeImagesByHash map[string][]HashInfo
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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