database

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2025 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Archive

type Archive struct {
	Path       string `gorm:"primaryKey"`
	SourcePath string
	Source     Source `gorm:"foreignKey:SourcePath"`
	CreatedAt  time.Time
}

type ArchiveAsset

type ArchiveAsset struct {
	ArchivePath string  `gorm:"primaryKey"`
	Path        string  `gorm:"primaryKey"`
	Archive     Archive `gorm:"foreignKey:ArchivePath"`
	Name        string
	Hash        int64
	ModTime     time.Time
	CreatedAt   time.Time
	Size        int64
}

type BackupArchive

type BackupArchive struct {
	Path       string
	CreatedAt  time.Time
	Size       int64
	AssetCount int
}

type BackupSource

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

func (*BackupSource) DeleteArchive

func (bs *BackupSource) DeleteArchive(ctx context.Context, archivePath string) error

func (*BackupSource) FindArchivedAssets

func (bs *BackupSource) FindArchivedAssets(ctx context.Context) (iter.Seq[asset.ArchivedAsset], error)

Find archived assets for this source. Only new versions are returned.

func (*BackupSource) FindArchives

func (bs *BackupSource) FindArchives(ctx context.Context, opts ...FindArchivesOptions) (iter.Seq[BackupArchive], error)

func (*BackupSource) FindMissingAssets

func (bs *BackupSource) FindMissingAssets(
	ctx context.Context,
	from iter.Seq[asset.Asset],
) (iter.Seq[asset.Asset], error)

Find assets that are not in the provided sequence.

func (*BackupSource) Path

func (bs *BackupSource) Path() string

func (*BackupSource) Register

func (bs *BackupSource) Register(ctx context.Context, from iter.Seq[asset.ArchivedAsset]) error

type Database

type Database struct {
	Lock   sync.Mutex
	Cli    *gorm.DB
	Logger zerolog.Logger
	DryRun bool
}

func (*Database) GetSource

func (d *Database) GetSource(ctx context.Context, path string) (*BackupSource, error)

func (*Database) IterSources

func (d *Database) IterSources(ctx context.Context) (iter.Seq[*BackupSource], error)

type FindArchivesOptions

type FindArchivesOptions func(*findArchivesOptions)

func WithFindArchivesLimit

func WithFindArchivesLimit(limit int) FindArchivesOptions

Limit the number of archives returned.

func WithFindArchivesMaxUncompressedSize

func WithFindArchivesMaxUncompressedSize(maxSize int64) FindArchivesOptions

Limit the maximum uncompressed size of archives returned.

func WithFindArchivesOnlyFullyBackedUp

func WithFindArchivesOnlyFullyBackedUp() FindArchivesOptions

Find only archives where all assets are also backed up in newer archives.

func WithFindArchivesOrderBy

func WithFindArchivesOrderBy(order FindArchivesOrderBy) FindArchivesOptions

Return the archives in a specific order.

type FindArchivesOrderBy

type FindArchivesOrderBy string
const (
	// Order by size, smallest first.
	FindArchivesOrderBySize FindArchivesOrderBy = "size"
)

type Source

type Source struct {
	Path      string `gorm:"primaryKey"`
	CreatedAt time.Time
}

Jump to

Keyboard shortcuts

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