finder

package module
v0.0.0-...-9a54b63 Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2022 License: MIT Imports: 17 Imported by: 0

README

Finder 🔍

Finder is a tool to sort and organize your files.

Installation 🪄

Currently, we only support the installation via go directly as shown below.

# go >= 1.17
# Using `go get` to install binaries is deprecated.
# The version suffix is mandatory.
go install github.com/nicklasfrahm/cmd/finder@latest

# go < 1.17
go get github.com/nicklasfrahm/cmd/finder

License 📄

This project is and will always be licensed under the terms of the MIT license.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateSchema

func CreateSchema(db *sqlx.DB) error

CreateSchema sets up the database tables to store the index of files and folders and additional application state.

func FolderSize

func FolderSize(folder string) (int64, error)

FolderSize returns the size of the specified folder.

func Index

func Index(folder string) error

Index builds an index of all files and folders in the specified directory.

func IndexFile

func IndexFile(db *sqlx.DB, job *IndexJob, progress *progressbar.ProgressBar) error

IndexFile indexes a file for a given IndexJob.

func ProcessFileStream

func ProcessFileStream(info *File) error

ProcessFileStream extracts file attributes while only reading the file in once. Currently it generates a SHA512 checksum of the file contents and detects the MIME type.

func Resume

func Resume(db *sqlx.DB) string

Resume attempts to resume an indexing operation. It returns the path of the last indexed file or folder.

Types

type File

type File struct {
	ID           string         `db:"id"`
	ParentID     sql.NullString `db:"parent_id"`
	Hash         sql.NullString `db:"hash"`
	Path         string         `db:"path"`
	Size         int64          `db:"size"`
	IsDir        bool           `db:"is_dir"`
	MIMEType     sql.NullString `db:"mime_type"`
	TimeModified time.Time      `db:"time_modified"`
	TimeCreated  time.Time      `db:"time_created"`
	TimeIndexed  time.Time      `db:"time_indexed"`
}

File represents an indexed file or folder in the file system.

func NewFile

func NewFile(path string) *File

NewFile creates a new File instance.

func (*File) Persist

func (file *File) Persist(db *sqlx.DB) error

Persist writes the file indexing information to the database.

type IndexJob

type IndexJob struct {
	Path  string
	Entry fs.DirEntry
}

IndexJob represents a job to index a file or folder.

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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