archive

package
v0.0.12 Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2023 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DeduplicateAll added in v0.0.12

func DeduplicateAll(archiveRoot string, duplicates [][]string, creator FileSystem) error

DeduplicateAll deduplicates all given files in the directory. This method actually executes the file operations if noDryRun is set.

Types

type Algorithm

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

func NewAlgorithm

func NewAlgorithm(src, dst string) *Algorithm

NewAlgorithm returns a new Algorithm.

func (*Algorithm) Init added in v0.0.10

func (a *Algorithm) Init() error

Init creates all required target directories

func (*Algorithm) Sort

func (a *Algorithm) Sort(fname string) (string, error)

type Copier

type Copier func(src, dst string, hFunc hash.Hash) (hashSum []byte, err error)

type DateExtractor

type DateExtractor func(fname string) (time.Time, error)

type DeDupTask added in v0.0.12

type DeDupTask struct {
	// ToKeep is the file path of the original to keep
	ToKeep string
	// ReCreateLinks are files which should be hard link to ToKeep. If they are already present, they should be deleted and recreated
	ReCreateLinks []string
	// DeleteFiles are files
	DeleteFiles []string
}

func DeDuplicate added in v0.0.12

func DeDuplicate(archiveRoot string, duplicateFiles []string) (DeDupTask, error)

DeDuplicate files in the given archiveRoot. All files in duplicateFiles must start with the prefix archiveRoot. This function assumes the canonical archive layout: /archiveRoot/

/ YEAR
   / Month1
   / Month2
/ origin
   / dirOne
   / dirTwo

The file in DedupTask.ToKeep will be in the directory /YEAR/MONTH. If there are multiple files in the /YEAR/MONTH directories, the first file is kept. At most one file in every directory below /origin is kept.

type DirectoryCreator

type DirectoryCreator func(dirPath string, perm os.FileMode) error

type FileDeleter added in v0.0.12

type FileDeleter func(file string) error

type FileSystem added in v0.0.12

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

func NewLoggingFileSystem added in v0.0.12

func NewLoggingFileSystem() FileSystem

func NewOSFileSystem added in v0.0.12

func NewOSFileSystem() FileSystem
func (fs FileSystem) CreateLinks(paths []string, target string) error

createLinks create a symlink from every path in paths to the given target

func (FileSystem) EnsureAbsent added in v0.0.12

func (fs FileSystem) EnsureAbsent(name string) error

EnsureAbsent removes the given directory and returns an error if file is not deleted

func (FileSystem) EnsureDirectory added in v0.0.12

func (fs FileSystem) EnsureDirectory(name string) error

EnsureDirectory creates the directory recursive

type IsMedia

type IsMedia func(fname string) (bool, error)

type Linker

type Linker func(old, new string) error

type Watcher

type Watcher interface {
	Channels() (chan fsnotify.Event, chan error)
}

Jump to

Keyboard shortcuts

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