fs

package
v0.0.0-...-09fc46a Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2023 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PERMS_DIR  os.FileMode = 0755 // Default permissions for directories
	PERMS_FILE os.FileMode = 0644 // Default permissions for files
)

Variables

View Source
var (
	ErrNotInitialized = fmt.Errorf("Repository storage is not initialized")
	ErrEmptyRepoName  = fmt.Errorf("Repository name can't be empty")
	ErrEmptyPath      = fmt.Errorf("Path to file can't be empty")
	ErrEmptyArchName  = fmt.Errorf("Arch name can't be empty")
	ErrUnknownArch    = fmt.Errorf("Unknown or unsupported architecture")
	ErrPseudoArch     = fmt.Errorf("Noarch is pseudo architecture and can't be used")
	ErrNilDepot       = fmt.Errorf("Can't find depot for given repository or architecture")
)
View Source
var DirNameValidatorRegex = regexp.MustCompile(`[a-zA-Z0-9]+`)

DirNameValidatorRegex is directory name validation regexp

Functions

func RegisterFunc

func RegisterFunc(dbType, name string, impl interface{}, pure bool) error

RegisterFunc registers new custom function for given DB type Notice that you can not register new functions after creating new storage

Types

type DBBundle

type DBBundle map[string]*sql.DB

DBBundle is map [db type] → [SQL connection]

type Depot

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

Depot is storage for specific repository (type + arch)

func (*Depot) AddPackage

func (d *Depot) AddPackage(rpmFile string) error

AddPackage adds package to depot

func (*Depot) CacheDB

func (d *Depot) CacheDB(dbType string) error

CacheDB caches (saves unpacked DB file) SQLite DB

func (*Depot) CheckCache

func (d *Depot) CheckCache() error

CheckCache checks if cache is valid and healthy

func (*Depot) GetDB

func (d *Depot) GetDB(dbType string) (*sql.DB, error)

GetDB returns connection to SQLite DB

func (*Depot) GetDBFilePath

func (d *Depot) GetDBFilePath(dbType string) string

GetDBFilePath returns path to SQLite DB file

func (*Depot) GetMetaIndex

func (d *Depot) GetMetaIndex() (*meta.Index, error)

GetMetaIndex reads repository metadata

func (*Depot) GetMetaIndexPath

func (d *Depot) GetMetaIndexPath() string

GetMetaIndexPath returns path to metadata index file (repomd.xml)

func (*Depot) GetPackagePath

func (d *Depot) GetPackagePath(rpmFileRelPath string) string

GetPackagePath returns full path to package RPM file

func (*Depot) HasPackage

func (d *Depot) HasPackage(rpmFileName string) bool

HasPackage checks if depot contains file with given name

func (*Depot) InvalidateCache

func (d *Depot) InvalidateCache() error

InvalidateCache invalidates repository cache

func (*Depot) IsCacheValid

func (d *Depot) IsCacheValid() bool

IsCacheValid checks if database files was updated and depot contains outdated metadata info and keeps connection to outdated SQL databases

func (*Depot) IsDBCached

func (d *Depot) IsDBCached(dbType string) bool

IsDBCached returns true if SQLite DB is cached

func (*Depot) IsEmpty

func (d *Depot) IsEmpty() bool

IsEmpty returns true if repository is empty (no packages)

func (*Depot) OpenDB

func (d *Depot) OpenDB(dbType string) error

OpenDB opens SQLite DB

func (*Depot) Reindex

func (d *Depot) Reindex(full bool) error

Reindex generates index metadata for the given repository and arch

func (*Depot) RemovePackage

func (d *Depot) RemovePackage(rpmFile string) error

RemovePackage removes package from depot

type DepotBundle

type DepotBundle map[string]*Depot

RepoStorageBundle is map [repo name] → [repo storage]

type Options

type Options struct {
	DataDir  string // Path to directory with RPM files
	CacheDir string // Path to directory for cached data

	SplitFiles bool // Split files to separate directories

	User      string      // Repository data directory owner username
	Group     string      // Repository data directory owner group
	DirPerms  os.FileMode // Permissions for directories
	FilePerms os.FileMode // Permissions for files
}

Options is storage options

func (*Options) GetDirPerms

func (o *Options) GetDirPerms() os.FileMode

GetDirPerms returns permissions for directories

func (*Options) GetFilePerms

func (o *Options) GetFilePerms() os.FileMode

GetFilePerms returns permissions for files

func (*Options) Validate

func (o *Options) Validate() error

Validate validates storage data options

type Storage

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

Storage is repository storage

func NewStorage

func NewStorage(dataOptions *Options, indexOptions *index.Options) (*Storage, error)

NewStorage creates new FS storage

func (*Storage) AddPackage

func (s *Storage) AddPackage(repo, rpmFilePath string) error

AddPackage adds package file to the given repository Important: This method DO NOT run repository reindex

func (*Storage) CopyPackage

func (s *Storage) CopyPackage(fromRepo, toRepo, arch, rpmFileRelPath string) error

CopyPackage copies file from one repository to another Important: This method DO NOT run repository reindex

func (*Storage) GetBinDepot

func (s *Storage) GetBinDepot(repo string) *Depot

GetBinDepot returns any depot with binary packages (useful for working with noarch packages)

func (*Storage) GetDB

func (s *Storage) GetDB(repo, arch, dbType string) (*sql.DB, error)

GetDB returns connection to SQLite DB

func (*Storage) GetDepot

func (s *Storage) GetDepot(repo, arch string) *Depot

GetDepot creates new depot or returns one from the cache

func (*Storage) GetModTime

func (s *Storage) GetModTime(repo, arch string) (time.Time, error)

GetModTime returns date of repository index modification

func (*Storage) GetPackagePath

func (s *Storage) GetPackagePath(repo, arch, rpmFileRelPath string) string

GetPackagePath returns full path to package RPM file

func (*Storage) HasArch

func (s *Storage) HasArch(repo, arch string) bool

HasArch returns true if repository storage contains directory for specific arch

func (*Storage) HasPackage

func (s *Storage) HasPackage(repo, arch, rpmFileName string) bool

HasPackage checks if repository contains file with given name

func (*Storage) HasRepo

func (s *Storage) HasRepo(repo string) bool

HasRepo returns true if given repositry exists

func (*Storage) Initialize

func (s *Storage) Initialize(repoList, archList []string) error

Initialize initializes the new repository storage and creates all required directories

func (*Storage) InvalidateCache

func (s *Storage) InvalidateCache() error

InvalidateCache invalidates cache and removes SQLite files from cache directory

func (*Storage) IsCacheValid

func (s *Storage) IsCacheValid(repo, arch string) bool

IsCacheValid returns true if cache is valid

func (*Storage) IsEmpty

func (s *Storage) IsEmpty(repo, arch string) bool

IsEmpty returns true if repository is empty (no packages)

func (*Storage) IsInitialized

func (s *Storage) IsInitialized() bool

IsInitialized returns true if repository already initialized and ready for work

func (*Storage) PurgeCache

func (s *Storage) PurgeCache() error

PurgeCache deletes all SQLite files from cache directory

func (*Storage) Reindex

func (s *Storage) Reindex(repo, arch string, full bool) error

Reindex generates index metadata for the given repository and arch

func (*Storage) RemovePackage

func (s *Storage) RemovePackage(repo, arch, rpmFileRelPath string) error

RemovePackage removes package with given relative path from the given repository Important: This method DO NOT run repository reindex

func (*Storage) WarmupCache

func (s *Storage) WarmupCache(repo, arch string) error

WarmupCache warmups cache

Jump to

Keyboard shortcuts

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