icopy

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Dec 23, 2025 License: GPL-3.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// FastHashThreshold is the file size limit (50 MB) above which we switch to partial hashing
	FastHashThreshold = 50 * 1024 * 1024
	// ChunkSize is the size of the chunks to read for partial hashing (1 MB)
	ChunkSize = 1 * 1024 * 1024
)

Variables

This section is empty.

Functions

func CloseBadgerDB

func CloseBadgerDB(db *badger.DB)

func ComputeFileHash

func ComputeFileHash(filePath string, useFastHash bool) (string, error)

ComputeFileHash calculates a hash for the file. If useFastHash is true and the file is larger than FastHashThreshold, it computes a partial hash based on the beginning, middle, and end of the file. Otherwise, it computes the full MD5.

func ExtractHeicExif

func ExtractHeicExif(r io.ReaderAt) ([]byte, error)

ExtractHeicExif parses a HEIC file (ISOBMFF) and extracts the raw EXIF data block.

func GetBadgerDBValue

func GetBadgerDBValue(db *badger.DB, hashKey string) (string, error)

func IterateWithPrefix

func IterateWithPrefix(db *badger.DB, prefix string) ([]string, error)

func Md5Sum

func Md5Sum(filePath string) (string, error)

Md5Sum returns the MD5 checksum of the file at the given path.

func OpenBadgerDB

func OpenBadgerDB(path string) (*badger.DB, error)

func PutBadgerDB

func PutBadgerDB(db *badger.DB, hashKey string, fileNameValue string) error

func ReadJpegDate

func ReadJpegDate(ctx context.Context, db *badger.DB, src_dirname string, options ScanOptions) ([]FileObject, []ErroredFileObject)

func ReadVideoCreationTimeMetadata

func ReadVideoCreationTimeMetadata(ctx context.Context, db *badger.DB, src_dirname string, options ScanOptions) ([]FileObject, []ErroredFileObject)

func ScanAndGenerateMd5sumFiles

func ScanAndGenerateMd5sumFiles(ctx context.Context, db *badger.DB, dirname string, prefix string, options ScanOptions)

func ScanFiles

func ScanFiles(ctx context.Context, src_dirname string, dst_dirname string, options ScanOptions)

func SortFilesByDate

func SortFilesByDate(files []FileObject)

Types

type ErroredFileObject

type ErroredFileObject struct {
	Name         string    `json:"name"`
	Path         string    `json:"path"`
	DateTime     time.Time `json:"date_time"`
	ErrorMessage string    `json:"error_message"`
}

type FileObject

type FileObject struct {
	Name     string    `json:"name"`
	Path     string    `json:"path"`
	DateTime time.Time `json:"date_time"`
	Md5Sum   string    `json:"md5sum"`
}

func RemoveSourceFile

func RemoveSourceFile(src_dirname string) []FileObject

type FileProcessor

type FileProcessor struct {
	Overwrite    string
	ForceCopy    bool
	Recursive    bool
	DateFmt      string
	UseFastHash  bool
	NumWorkers   int
	ProgressChan chan string
}

func (*FileProcessor) CopyImageFiles

func (fp *FileProcessor) CopyImageFiles(ctx context.Context, srcdir string, destdir string) ([]FileObject, []ErroredFileObject, []FileObject)

func (*FileProcessor) CopyVideoFiles

func (fp *FileProcessor) CopyVideoFiles(ctx context.Context, srcdir string, destdir string) ([]FileObject, []ErroredFileObject, []FileObject)

type MatchObject

type MatchObject struct {
	SrcFileName string `json:"src_file_name"`
	DstFileName string `json:"dst_file_name"`
}

func ValidateMd5sumFiles

func ValidateMd5sumFiles(ctx context.Context, src_prefix string, dst_prefix string) []MatchObject

type ScanOptions

type ScanOptions struct {
	Recursive    bool
	NumWorkers   int
	UseFastHash  bool
	ProgressChan chan string
}

Jump to

Keyboard shortcuts

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