utils

package
v0.0.0-...-d3ca24b Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2015 License: BSD-3-Clause Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FileWrite

func FileWrite(path string, r io.Reader, uid, gid int, perms string) (int64, error)

func GetAbsPath

func GetAbsPath(listener, db_path string) string

func GetListenerFromDir

func GetListenerFromDir(dir string) string

func GetListenerHomeDir

func GetListenerHomeDir(listener string) string

Fetches the home directory of the listener from the config file

func GetListenerUploadPath

func GetListenerUploadPath(listener string) string

Fetches the base directory (upload path) from configuration file

func GetLocalIp

func GetLocalIp() string

func GetMd5Checksum

func GetMd5Checksum(filepath string) string

func GetRelativePath

func GetRelativePath(listener, local_path string) string

Gets the relative path based on the home directory, essentially stripping the listener, home directory from the absolute path

func GetRelativeUploadPath

func GetRelativeUploadPath(listener, local_path string) string

Gets the relative path for the item by trimming the absolute path with the home dir, it then appends the base directory (Upload Path) to the front of the relative path.

func GetSystemHostname

func GetSystemHostname() string

func ItemExists

func ItemExists(path string) (bool, error)

exists returns whether the given file or directory exists or not

func MatchesIgnore

func MatchesIgnore(directory_path, filename string) bool

func ReadConfigFromFile

func ReadConfigFromFile(configfile string)

Types

type AppError

type AppError struct {
	Error   error
	Message string
	Code    int
	Stack   string
}

type BaseConfig

type BaseConfig struct {
	ListenPort  string `toml:"listen_port"`
	RescanTime  int    `toml:"rescan"`
	StorageType string `toml:"storagetype"`
	LogLocation string `toml:"log_location"`
	LogLevel    string `toml:"log_level"`
}

type Configuration

type Configuration struct {
	ServerConfig BaseConfig
	S3Config     StorageS3 `toml:"StorageS3"`
	GDConfig     StorageGDrive
	Database     Database
	Listeners    map[string]Listener
}

func GetConfig

func GetConfig() *Configuration

type DataTable

type DataTable struct {
	Id          int       `db:"id"`
	Path        string    `db:"path"`
	IsDirectory bool      `db:"is_dir"`
	Filename    string    `db:"filename"`
	Directory   string    `db:"directory"`
	Checksum    string    `db:"checksum"`
	Atime       time.Time `db:"atime"`
	Mtime       time.Time `db:"mtime"`
	Perms       string    `db:"perms"`
	HostUpdated string    `db:"host_updated"`
	HostIPs     string    `db:"host_ips"`
	LastUpdate  time.Time `db:"last_update"`
}

type Database

type Database struct {
	Type string
	Dsn  string
}

type FsItem

type FsItem struct {
	Filename string
	Path     string
	Checksum string
	IsDir    bool
	Mtime    time.Time
	Perms    string
}

func GetFileInfo

func GetFileInfo(doc_path string) (FsItem, error)

func ListFilesInDir

func ListFilesInDir(doc_path string) []FsItem

type Listener

type Listener struct {
	Directory   string
	Excludes    string `toml:"excludes"`
	Uid         int
	Gid         int
	StorageType string `toml:"storagetype"`
	Bucket      string `toml:"bucket"`
	BasePath    string `toml:"basepath"`
}

type NodeTable

type NodeTable struct {
	Id         int       `db:"id"`
	HostName   string    `db:"hostname"`
	NodeIPs    string    `db:"host_ips"`
	Connected  time.Time `db:"connected_on"`
	LastUpdate time.Time `db:"last_update"`
}

type StorageGDrive

type StorageGDrive struct {
	Key    string
	Secret string
	Region string
}

type StorageS3

type StorageS3 struct {
	Key    string `toml:"key"`
	Secret string `toml:"secret"`
	Region string `toml:"region"`
}

Jump to

Keyboard shortcuts

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