sqlite

package
v0.0.0-...-82cad40 Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2020 License: GPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InitDB

func InitDB(path string) error

InitDB initializes tables. Supposed to be called on the very first run.

Types

type Client

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

Client is created when a new connection to the database is established Use NewClient() to create

func NewClient

func NewClient(filePath string) (*Client, error)

NewClient returns a new database connection.

func (*Client) AddDirectory

func (c *Client) AddDirectory(parent int64, name string, mode int) (*Metadata, error)

AddDirectory insert row with type folder into the database

func (*Client) Close

func (c *Client) Close()

Close terminates database connection.

func (*Client) CreateFile

func (c *Client) CreateFile(parent int64, name string, mode int, url string, hash string) (*Metadata, error)

CreateFile insert row with type file into the database

func (*Client) Delete

func (c *Client) Delete(inode int64) error

Delete removes file with specified inode from database

func (*Client) ForceInsert

func (c *Client) ForceInsert(md *Metadata) error

ForceInsert inserts metadata with provided inode, doesn't rely on autoincrement

func (*Client) Get

func (c *Client) Get(inode int64) (*Metadata, error)

Get returns file metadata with specified inode

func (*Client) GetChildren

func (c *Client) GetChildren(parent int64) ([]Metadata, error)

GetChildren returns files under the folder with specified inode

func (*Client) GetFileCount

func (c *Client) GetFileCount() (int64, error)

GetFileCount returns number of rows of type common.DrvFile

func (*Client) GetRowCount

func (c *Client) GetRowCount() (int, error)

GetRowCount returns total number of rows

func (*Client) GetRows

func (c *Client) GetRows(limit int, offset int) ([]Metadata, error)

GetRows returns rows starting from specified offset with specified limit

func (*Client) GetTotalSize

func (c *Client) GetTotalSize() (int64, error)

func (*Client) Insert

func (c *Client) Insert(md *Metadata) error

Insert inserts metadata to database

func (*Client) IsValidDatabase

func (c *Client) IsValidDatabase() bool

IsValidDatabase checks whether `files` table exists

func (*Client) Search

func (c *Client) Search(parent int64, name string) (*Metadata, error)

Search looks for file with specified name under specified inode

func (*Client) Update

func (c *Client) Update(md *Metadata) error

Update updates related row with new metadata

type Metadata

type Metadata struct {
	Inode  int64
	Name   string
	URL    string
	Size   int64
	Mode   int
	Type   int
	Parent int64
	NLink  int
	Hash   string
}

Jump to

Keyboard shortcuts

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