index

package
v2.2.4-rc1+incompatible Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2021 License: AGPL-3.0 Imports: 29 Imported by: 0

Documentation

Overview

Package index provides ready-to-use tables and DAOs for storing hierarchical data using the nested sets pattern

  • Copyright (c) 2018. Abstrium SAS <team (at) pydio.com>

  • This file is part of Pydio Cells. *

  • Pydio Cells is free software: you can redistribute it and/or modify

  • it under the terms of the GNU Affero General Public License as published by

  • the Free Software Foundation, either version 3 of the License, or

  • (at your option) any later version. *

  • Pydio Cells is distributed in the hope that it will be useful,

  • but WITHOUT ANY WARRANTY; without even the implied warranty of

  • MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the

  • GNU Affero General Public License for more details. *

  • You should have received a copy of the GNU Affero General Public License

  • along with Pydio Cells. If not, see <http://www.gnu.org/licenses/>. *

  • The latest code can be found at <https://pydio.com>.

  • Copyright (c) 2018. Abstrium SAS <team (at) pydio.com>

  • This file is part of Pydio Cells. *

  • Pydio Cells is free software: you can redistribute it and/or modify

  • it under the terms of the GNU Affero General Public License as published by

  • the Free Software Foundation, either version 3 of the License, or

  • (at your option) any later version. *

  • Pydio Cells is distributed in the hope that it will be useful,

  • but WITHOUT ANY WARRANTY; without even the implied warranty of

  • MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the

  • GNU Affero General Public License for more details. *

  • You should have received a copy of the GNU Affero General Public License

  • along with Pydio Cells. If not, see <http://www.gnu.org/licenses/>. *

  • The latest code can be found at <https://pydio.com>.

  • Copyright (c) 2018. Abstrium SAS <team (at) pydio.com>

  • This file is part of Pydio Cells. *

  • Pydio Cells is free software: you can redistribute it and/or modify

  • it under the terms of the GNU Affero General Public License as published by

  • the Free Software Foundation, either version 3 of the License, or

  • (at your option) any later version. *

  • Pydio Cells is distributed in the hope that it will be useful,

  • but WITHOUT ANY WARRANTY; without even the implied warranty of

  • MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the

  • GNU Affero General Public License for more details. *

  • You should have received a copy of the GNU Affero General Public License

  • along with Pydio Cells. If not, see <http://www.gnu.org/licenses/>. *

  • The latest code can be found at <https://pydio.com>.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewDAO

func NewDAO(o dao.DAO, rootNodeId string) dao.DAO

NewDAO for the common sql index

func NewNode

func NewNode(treeNode *tree.Node, path mtree.MPath, filenames []string) *mtree.TreeNode

NewNode utils

Types

type BatchSend

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

BatchSend sql structure

func NewBatchSend

func NewBatchSend() *BatchSend

NewBatchSend Creation of the channels

func (*BatchSend) Close

func (b *BatchSend) Close() error

Close the Batch

func (*BatchSend) Send

func (b *BatchSend) Send(arg interface{})

Send a node to the batch

type CacheDAO

type CacheDAO interface {
	// PathCreateNoAdd does the same as Path(create=true) but does not really
	// create the node in the cache, just find a firstAvailableIndex
	PathCreateNoAdd(strpath string) (mtree.MPath, *mtree.TreeNode, error)
}

type DAO

type DAO interface {
	Path(strpath string, create bool, reqNode ...*tree.Node) (mtree.MPath, []*mtree.TreeNode, error)

	// Add a node in the tree
	AddNode(*mtree.TreeNode) error
	// SetNode updates a node, including its tree position
	SetNode(*mtree.TreeNode) error
	// Update a node metadata, without touching its tree position
	SetNodeMeta(*mtree.TreeNode) error
	// Remove a node from the tree
	DelNode(*mtree.TreeNode) error

	// Simple Add / Set / Delete
	AddNodeStream(int) (chan *mtree.TreeNode, chan error)
	Flush(bool) error

	// Batch Add / Set / Delete
	GetNodes(...mtree.MPath) chan *mtree.TreeNode
	SetNodes(string, int64) sql.BatchSender

	// Getters
	GetNode(mtree.MPath) (*mtree.TreeNode, error)
	GetNodeByUUID(string) (*mtree.TreeNode, error)
	GetNodeChildren(mtree.MPath) chan *mtree.TreeNode
	GetNodeTree(mtree.MPath) chan *mtree.TreeNode
	GetNodeChild(mtree.MPath, string) (*mtree.TreeNode, error)
	GetNodeLastChild(mtree.MPath) (*mtree.TreeNode, error)
	GetNodeFirstAvailableChildIndex(mtree.MPath) (uint64, error)
	GetNodeChildrenCounts(mtree.MPath) (int, int)
	MoveNodeTree(nodeFrom *mtree.TreeNode, nodeTo *mtree.TreeNode) error

	ResyncDirtyEtags(rootNode *mtree.TreeNode) error
	CleanResourcesOnDeletion() (error, string)
	LostAndFounds() ([]LostAndFound, error)
	FixLostAndFound(lost LostAndFound) error
	FixRandHash2(excludes ...LostAndFound) (int64, error)

	GetSQLDAO() sql.DAO
}

DAO interface

func GetDAOCache

func GetDAOCache(session string) DAO

GetDAOCache returns the cache based on the session name

func NewDAOCache

func NewDAOCache(session string, d DAO) DAO

NewDAOCache wraps a cache around the dao

func NewFolderSizeCacheDAO

func NewFolderSizeCacheDAO(dao DAO) DAO

NewFolderSizeCacheDAO provides a middleware implementation of the index sql dao that removes duplicate entries of the .pydio file that have the same etag at the same level

func NewHiddenFileDuplicateRemoverDAO

func NewHiddenFileDuplicateRemoverDAO(dao DAO) DAO

NewHiddenFileDuplicateRemoverDAO provides a middleware implementation of the index sql dao that removes duplicate entries of the .pydio file that have the same etag at the same level

type DAOWrapper

type DAOWrapper func(d DAO) DAO

type FolderSizeCacheSQL

type FolderSizeCacheSQL struct {
	DAO
}

FolderSizeCacheSQL implementation

func (*FolderSizeCacheSQL) AddNode

func (dao *FolderSizeCacheSQL) AddNode(node *mtree.TreeNode) error

Add a node in the tree

func (*FolderSizeCacheSQL) DelNode

func (dao *FolderSizeCacheSQL) DelNode(node *mtree.TreeNode) error

Remove a node from the tree

func (*FolderSizeCacheSQL) GetNode

func (dao *FolderSizeCacheSQL) GetNode(path mtree.MPath) (*mtree.TreeNode, error)

GetNode from path

func (*FolderSizeCacheSQL) GetNodeByUUID

func (dao *FolderSizeCacheSQL) GetNodeByUUID(uuid string) (*mtree.TreeNode, error)

GetNodeByUUID returns the node stored with the unique uuid

func (*FolderSizeCacheSQL) GetNodeChildren

func (dao *FolderSizeCacheSQL) GetNodeChildren(path mtree.MPath) chan *mtree.TreeNode

GetNodeChildren List

func (*FolderSizeCacheSQL) GetNodeTree

func (dao *FolderSizeCacheSQL) GetNodeTree(path mtree.MPath) chan *mtree.TreeNode

GetNodeTree List from the path

func (*FolderSizeCacheSQL) GetSQLDAO

func (dao *FolderSizeCacheSQL) GetSQLDAO() sql.DAO

func (*FolderSizeCacheSQL) MoveNodeTree

func (dao *FolderSizeCacheSQL) MoveNodeTree(nodeFrom *mtree.TreeNode, nodeTo *mtree.TreeNode) error

MoveNodeTree move all the nodes belonging to a tree by calculating the new mpathes

func (*FolderSizeCacheSQL) Path

func (dao *FolderSizeCacheSQL) Path(strpath string, create bool, reqNode ...*tree.Node) (mtree.MPath, []*mtree.TreeNode, error)

func (*FolderSizeCacheSQL) SetNode

func (dao *FolderSizeCacheSQL) SetNode(node *mtree.TreeNode) error

SetNode updates a node, including its tree position

type HiddenFileDuplicateRemoverSQL

type HiddenFileDuplicateRemoverSQL struct {
	DAO
}

HiddenFileDuplicateRemoverSQL implementation

func (*HiddenFileDuplicateRemoverSQL) Flush

func (dao *HiddenFileDuplicateRemoverSQL) Flush(final bool) error

Flush the database after big updates

func (*HiddenFileDuplicateRemoverSQL) GetSQLDAO

func (dao *HiddenFileDuplicateRemoverSQL) GetSQLDAO() sql.DAO

type IndexSQL

type IndexSQL struct {
	*sql.Handler
	// contains filtered or unexported fields
}

IndexSQL implementation

func (*IndexSQL) AddNode

func (dao *IndexSQL) AddNode(node *mtree.TreeNode) error

AddNode to the underlying SQL DB.

func (*IndexSQL) AddNodeStream

func (dao *IndexSQL) AddNodeStream(max int) (chan *mtree.TreeNode, chan error)

AddNodeStream creates a channel to write to the SQL database

func (*IndexSQL) CleanResourcesOnDeletion

func (dao *IndexSQL) CleanResourcesOnDeletion() (error, string)

CleanResourcesOnDeletion revert the creation of the table for a datasource

func (*IndexSQL) DelNode

func (dao *IndexSQL) DelNode(node *mtree.TreeNode) error

DelNode from database

func (*IndexSQL) FixLostAndFound

func (dao *IndexSQL) FixLostAndFound(lost LostAndFound) error

FixLostAndFound receives LostAndFound that are ready for deletion

func (*IndexSQL) FixRandHash2

func (dao *IndexSQL) FixRandHash2(excludes ...LostAndFound) (int64, error)

FixRandHash2 looks up for hash2 in the form 'random-%' and recompute them as proper has of parents + name

func (*IndexSQL) Flush

func (dao *IndexSQL) Flush(final bool) error

Flush the database in case of cached inserts

func (*IndexSQL) GetNode

func (dao *IndexSQL) GetNode(path mtree.MPath) (*mtree.TreeNode, error)

GetNode from path

func (*IndexSQL) GetNodeByUUID

func (dao *IndexSQL) GetNodeByUUID(uuid string) (*mtree.TreeNode, error)

GetNodeByUUID returns the node stored with the unique uuid

func (*IndexSQL) GetNodeChild

func (dao *IndexSQL) GetNodeChild(reqPath mtree.MPath, reqName string) (*mtree.TreeNode, error)

GetNodeChild from node path whose name matches

func (*IndexSQL) GetNodeChildren

func (dao *IndexSQL) GetNodeChildren(path mtree.MPath) chan *mtree.TreeNode

GetNodeChildren List

func (*IndexSQL) GetNodeChildrenCounts added in v1.5.0

func (dao *IndexSQL) GetNodeChildrenCounts(path mtree.MPath) (int, int)

GetNodeChildrenCounts List

func (*IndexSQL) GetNodeFirstAvailableChildIndex

func (dao *IndexSQL) GetNodeFirstAvailableChildIndex(reqPath mtree.MPath) (uint64, error)

GetNodeFirstAvailableChildIndex from path

func (*IndexSQL) GetNodeLastChild

func (dao *IndexSQL) GetNodeLastChild(reqPath mtree.MPath) (*mtree.TreeNode, error)

GetNodeLastChild from path

func (*IndexSQL) GetNodeTree

func (dao *IndexSQL) GetNodeTree(path mtree.MPath) chan *mtree.TreeNode

GetNodeTree List from the path

func (*IndexSQL) GetNodes

func (dao *IndexSQL) GetNodes(mpathes ...mtree.MPath) chan *mtree.TreeNode

GetNodes List

func (*IndexSQL) GetSQLDAO

func (dao *IndexSQL) GetSQLDAO() sql.DAO

func (*IndexSQL) Init

func (dao *IndexSQL) Init(options configx.Values) error

Init handles the db version migration and prepare the statements

func (*IndexSQL) LostAndFounds

func (dao *IndexSQL) LostAndFounds() (output []LostAndFound, err error)

func (*IndexSQL) MoveNodeTree

func (dao *IndexSQL) MoveNodeTree(nodeFrom *mtree.TreeNode, nodeTo *mtree.TreeNode) error

MoveNodeTree move all the nodes belonging to a tree by calculating the new mpathes

func (*IndexSQL) Path

func (dao *IndexSQL) Path(strpath string, create bool, reqNode ...*tree.Node) (mtree.MPath, []*mtree.TreeNode, error)

func (*IndexSQL) ResyncDirtyEtags

func (dao *IndexSQL) ResyncDirtyEtags(rootNode *mtree.TreeNode) error

ResyncDirtyEtags ensures that etags are rightly calculated

func (*IndexSQL) SetNode

func (dao *IndexSQL) SetNode(node *mtree.TreeNode) error

SetNode in replacement of previous node

func (*IndexSQL) SetNodeMeta

func (dao *IndexSQL) SetNodeMeta(node *mtree.TreeNode) error

SetNode in replacement of previous node

func (*IndexSQL) SetNodes

func (dao *IndexSQL) SetNodes(etag string, deltaSize int64) sql.BatchSender

SetNodes returns a channel and waits for arriving nodes before updating them in batch.

type LostAndFound

type LostAndFound interface {
	fmt.Stringer
	IsDuplicate() bool
	IsLostParent() bool
	IsDir() bool

	GetUUIDs() []string
	MarkForDeletion([]string)
}

Jump to

Keyboard shortcuts

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