file

package
v0.0.0-...-9fc6fd2 Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2023 License: MIT Imports: 19 Imported by: 0

Documentation

Overview

*

** Loader will load all the files and directories at a root. It assumes that the root already exists so it skips
** sending the starting directory to the Skipper and Loader functions.

** MCFileLoader loads files and directories into a Materials Commons project. It does various checks to see
** if the file or directory already exists.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultSkipper

func DefaultSkipper(path string, finfo os.FileInfo) bool

DefaultSkipper doesn't skip any entries.

func Exists

func Exists(path string) bool

Exists returns true if path exists.

func IsDir

func IsDir(path string) bool

IsDir returns true if path is a directory.

func MCFileDir

func MCFileDir(path, fileID string) string

func MoveFile

func MoveFile(src, dst string, removeSrc bool) error

Types

type BackgroundLoader

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

func NewBackgroundLoader

func NewBackgroundLoader(mcdir string, numberOfWorkers int, db store.DB) *BackgroundLoader

func (*BackgroundLoader) Start

func (l *BackgroundLoader) Start(c context.Context)

type DirectoryLoader

type DirectoryLoader interface {
	LoadFileOrDir(path string, info os.FileInfo) error
}

type ExcludeListSkipper

type ExcludeListSkipper struct {
	ExcludeList map[string]string
}

ExcludeListSkipper contains a list of entries to skip

func NewExcludeListSkipper

func NewExcludeListSkipper(excludeList []string) *ExcludeListSkipper

NewExcludeListSkipper creates a new ExludeListSkipper from the list of entries to exclude.

func (*ExcludeListSkipper) Skipper

func (s *ExcludeListSkipper) Skipper(path string, finfo os.FileInfo) bool

type FileAndDirFilter

type FileAndDirFilter interface {
	IsIncludedFile(filePath string) bool
	IsIncludedDir(dirPath string) bool
}

type Loader

type Loader struct {
	Skipper         Skipper         // Method to call to see if this entry should be skipped
	DirectoryLoader DirectoryLoader // Interface to call to load the entry if it is not skipped
}

func NewFileLoader

func NewFileLoader(skipper Skipper, loader DirectoryLoader) *Loader

func (*Loader) LoadFiles

func (l *Loader) LoadFiles(path string) error

func (*Loader) LoadFilesWithCancel

func (l *Loader) LoadFilesWithCancel(path string, c context.Context) error

type MCFileLoader

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

func NewMCFileLoader

func NewMCFileLoader(root, owner, mcdir string, project model.ProjectSimpleModel, dfStore *store.DatafilesStore, ddStore *store.DatadirsStore) *MCFileLoader

func (*MCFileLoader) LoadFileOrDir

func (l *MCFileLoader) LoadFileOrDir(path string, finfo os.FileInfo) error

type MediaType

type MediaType struct {
	Mime        string
	Description string
}

func GetMediaTypeByExtension

func GetMediaTypeByExtension(path string) MediaType

type ProjectDownload

type ProjectDownload struct {
	ProjectID string
	User      model.UserSchema
	// contains filtered or unexported fields
}

func NewProjectDownload

func NewProjectDownload(projectID string, user model.UserSchema, ddirsStore *store.DatadirsStore) *ProjectDownload

func (*ProjectDownload) CreateProjectDownloadDirectory

func (d *ProjectDownload) CreateProjectDownloadDirectory(basePath string) error

CreateProjectDownloadDirectory creates a download directory for the given project. It will walk through the projects directories and create them in this temporary download. It will then create a link to in this directory that points at the file entry in the Materials Commons store. The reason this needs to be done is that the Materials Commons store is an object store (like S3), where as Globus (and users) need to see the imposed directory structure. This is reconstructed from the database. Links to files are used so we don't have to create copies of the files.

type Skipper

type Skipper func(path string, finfo os.FileInfo) bool

type Zipper

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

func CreateZipper

func CreateZipper(zipfilePath string) (*Zipper, error)

func (*Zipper) AddToZipfile

func (z *Zipper) AddToZipfile(filePath string, pathInZip string) error

func (*Zipper) Close

func (z *Zipper) Close() error

func (*Zipper) RemoveZip

func (z *Zipper) RemoveZip()

Jump to

Keyboard shortcuts

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