op

package
v4.3.6 Latest Latest
Warning

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

Go to latest
Published: Aug 8, 2025 License: AGPL-3.0 Imports: 28 Imported by: 0

Documentation

Overview

Package op provides operations for OpenList's core functionality

Package op provides operations for OpenList's core functionality

Package op provides operations for OpenList's core functionality

Package op provides operations for OpenList's core functionality

Package op provides operations for OpenList's core functionality

Index

Constants

View Source
const (
	// WORK represents an active storage status
	WORK = "work"
	// DISABLED represents a disabled storage status
	DISABLED = "disabled"
	// RootName is the identifier for the root storage/directory
	RootName = "root"
)

Storage status constants

Variables

View Source
var MigrationSettingItems map[string]MigrationValueItem

Functions

func ArchiveDecompress

func ArchiveDecompress(ctx context.Context, storage driver.Driver, srcPath, dstDirPath string, args model.ArchiveDecompressArgs, lazyCache ...bool) error

func ArchiveGet

func ArchiveGet(ctx context.Context, storage driver.Driver, path string, args model.ArchiveListArgs) (model.Obj, model.Obj, error)

func CallStorageHooks

func CallStorageHooks(typ string, storage driver.Driver)

CallStorageHooks calls all registered storage hooks

func Cancel2FAById added in v4.3.5

func Cancel2FAById(id uint) error

func Cancel2FAByUser

func Cancel2FAByUser(u *model.User) error

func ClearCache

func ClearCache(storage driver.Driver, path string)

func Copy

func Copy(ctx context.Context, storage driver.Driver, srcPath, dstDirPath string, lazyCache ...bool) error

Copy Just copy file[s] in a storage

func CreateMeta

func CreateMeta(u *model.Meta) error

func CreateSSHPublicKey

func CreateSSHPublicKey(key *model.SSHPublicKey) (error, bool)

CreateSSHPublicKey creates a new SSH public key for a user Returns an error and a boolean indicating if the error is due to validation (true) or system issues (false)

func CreateStorage

func CreateStorage(ctx context.Context, storage model.Storage) (uint, error)

CreateStorage Save the storage to database so storage can get an id then instantiate corresponding driver and save it in memory

func CreateUser

func CreateUser(u *model.User) error

func DelUserCache

func DelUserCache(username string) error

func DeleteCache added in v4.2.7

func DeleteCache(storage driver.Driver, path string)

func DeleteMetaById added in v4.3.5

func DeleteMetaById(id uint) error

func DeleteSSHPublicKeyByID

func DeleteSSHPublicKeyByID(keyID uint) error

DeleteSSHPublicKeyByID deletes an SSH public key by its ID

func DeleteSettingItemByKey

func DeleteSettingItemByKey(key string) error

func DeleteStorageById added in v4.3.5

func DeleteStorageById(ctx context.Context, id uint) error

func DeleteUserById added in v4.3.5

func DeleteUserById(id uint) error

func DisableStorage

func DisableStorage(ctx context.Context, id uint) error

func DriverExtract

func DriverExtract(ctx context.Context, storage driver.Driver, path string, args model.ArchiveInnerArgs) (*model.Link, model.Obj, error)

func EnableStorage

func EnableStorage(ctx context.Context, id uint) error

func Get

func Get(ctx context.Context, storage driver.Driver, path string) (model.Obj, error)

Get object from list of files

func GetAdmin

func GetAdmin() (*model.User, error)

func GetAllStorages

func GetAllStorages() []driver.Driver

func GetArchiveMeta

func GetArchiveMeta(ctx context.Context, storage driver.Driver, path string, args model.ArchiveMetaArgs) (*model.ArchiveMetaProvider, error)

func GetArchiveToolAndStream

func GetArchiveToolAndStream(ctx context.Context, storage driver.Driver, path string, args model.LinkArgs) (model.Obj, tool.Tool, []*stream.SeekableStream, error)

func GetBalancedStorage

func GetBalancedStorage(path string) driver.Driver

GetBalancedStorage get storage by path

func GetDriverInfoMap

func GetDriverInfoMap() map[string]driver.Info

func GetDriverNames

func GetDriverNames() []string

func GetGuest

func GetGuest() (*model.User, error)

func GetMetaById added in v4.3.5

func GetMetaById(id uint) (*model.Meta, error)

func GetMetaByPath

func GetMetaByPath(path string) (*model.Meta, error)

func GetMetas

func GetMetas(pageIndex, pageSize int) (metas []model.Meta, count int64, err error)

func GetNearestMeta

func GetNearestMeta(path string) (*model.Meta, error)

func GetPublicSettingItems

func GetPublicSettingItems() ([]model.SettingItem, error)

func GetPublicSettingsMap

func GetPublicSettingsMap() map[string]string

func GetSSHPublicKeyByIDAndUserID

func GetSSHPublicKeyByIDAndUserID(id uint, userID uint) (*model.SSHPublicKey, error)

GetSSHPublicKeyByIDAndUserID retrieves a specific SSH public key for a user Ensures the key belongs to the specified user

func GetSSHPublicKeyByUserID

func GetSSHPublicKeyByUserID(userID uint, pageIndex, pageSize int) (keys []model.SSHPublicKey, count int64, err error)

GetSSHPublicKeyByUserID retrieves a paginated list of SSH public keys for a user

func GetSettingItemByKey

func GetSettingItemByKey(key string) (*model.SettingItem, error)

func GetSettingItemInKeys

func GetSettingItemInKeys(keys []string) ([]model.SettingItem, error)

func GetSettingItems

func GetSettingItems() ([]model.SettingItem, error)

func GetSettingItemsByGroup

func GetSettingItemsByGroup(group int) ([]model.SettingItem, error)

func GetSettingItemsInGroups

func GetSettingItemsInGroups(groups []int) ([]model.SettingItem, error)

func GetSettingsMap

func GetSettingsMap() map[string]string

func GetStorageAndActualPath

func GetStorageAndActualPath(rawPath string) (storage driver.Driver, actualPath string, err error)

GetStorageAndActualPath Get the corresponding storage and actual path for path: remove the mount path prefix and join the actual root folder if exists

func GetStorageByMountPath

func GetStorageByMountPath(mountPath string) (driver.Driver, error)

func GetStorageVirtualFilesByPath

func GetStorageVirtualFilesByPath(prefix string) []model.Obj

GetStorageVirtualFilesByPath Obtain the virtual file generated by the storage according to the path for example, there are: /a/b,/a/c,/a/d/e,/a/b.balance1,/av GetStorageVirtualFilesByPath(/a) => b,c,d

func GetUnwrap

func GetUnwrap(ctx context.Context, storage driver.Driver, path string) (model.Obj, error)

func GetUserById added in v4.3.5

func GetUserById(id uint) (*model.User, error)

func GetUserByName

func GetUserByName(username string) (*model.User, error)

func GetUserByRole

func GetUserByRole(role int) (*model.User, error)

func GetUsers

func GetUsers(pageIndex, pageSize int) (users []model.User, count int64, err error)

func HandleObjsUpdateHook

func HandleObjsUpdateHook(parent string, objs []model.Obj)

HandleObjsUpdateHook calls all registered object update hooks

func HandleSettingItemHook

func HandleSettingItemHook(item *model.SettingItem) (hasHook bool, err error)

HandleSettingItemHook processes a setting item with its registered hook Returns:

  • hasHook: true if a hook was found and executed for the item
  • err: any error that occurred during hook execution

func HasStorage

func HasStorage(mountPath string) bool

func InternalExtract

func InternalExtract(ctx context.Context, storage driver.Driver, path string, args model.ArchiveInnerArgs) (io.ReadCloser, int64, error)

func IsUseOnlineAPI added in v4.3.1

func IsUseOnlineAPI(storageDriver driver.Driver) bool

func Key

func Key(storage driver.Driver, path string) string
func Link(ctx context.Context, storage driver.Driver, path string, args model.LinkArgs) (*model.Link, model.Obj, error)

Link get link, if is an url. should have an expiry time

func List

func List(ctx context.Context, storage driver.Driver, path string, args model.ListArgs) ([]model.Obj, error)

List files in storage, not contains virtual file

func ListArchive

func ListArchive(ctx context.Context, storage driver.Driver, path string, args model.ArchiveListArgs) ([]model.Obj, error)

func LoadStorage

func LoadStorage(ctx context.Context, storage model.Storage) error

LoadStorage load exist storage in db to memory

func MakeDir

func MakeDir(ctx context.Context, storage driver.Driver, path string, lazyCache ...bool) error

func Move

func Move(ctx context.Context, storage driver.Driver, srcPath, dstDirPath string, lazyCache ...bool) error

func MustSaveDriverStorage

func MustSaveDriverStorage(driver driver.Driver)

MustSaveDriverStorage call from specific driver

func Other

func Other(ctx context.Context, storage driver.Driver, args model.FsOtherArgs) (interface{}, error)

Other api

func Put

func Put(ctx context.Context, storage driver.Driver, dstDirPath string, file model.FileStreamer, up driver.UpdateProgress, lazyCache ...bool) error

func PutURL

func PutURL(ctx context.Context, storage driver.Driver, dstDirPath, dstName, url string, lazyCache ...bool) error

func RegisterDriver

func RegisterDriver(driver DriverConstructor)

func RegisterObjsUpdateHook

func RegisterObjsUpdateHook(hook ObjsUpdateHook)

RegisterObjsUpdateHook registers a new hook to be called when objects are updated

func RegisterSettingChangingCallback

func RegisterSettingChangingCallback(f func())

func RegisterSettingItemHook

func RegisterSettingItemHook(key string, hook SettingItemHook)

RegisterSettingItemHook registers a hook for a specific setting key

func RegisterStorageHook

func RegisterStorageHook(hook StorageHook)

RegisterStorageHook registers a new hook for storage operations

func Remove

func Remove(ctx context.Context, storage driver.Driver, path string) error

func Rename

func Rename(ctx context.Context, storage driver.Driver, srcPath, dstName string, lazyCache ...bool) error

func SaveSettingItem

func SaveSettingItem(item *model.SettingItem) (err error)

func SaveSettingItems

func SaveSettingItems(items []model.SettingItem) error

func SettingCacheUpdate

func SettingCacheUpdate()

func UpdateMeta

func UpdateMeta(u *model.Meta) error

func UpdateSSHPublicKey

func UpdateSSHPublicKey(key *model.SSHPublicKey) error

UpdateSSHPublicKey updates an existing SSH public key

func UpdateStorage

func UpdateStorage(ctx context.Context, storage model.Storage) error

UpdateStorage update storage get old storage first drop the storage then reinitialize

func UpdateUser

func UpdateUser(u *model.User) error

Types

type DriverConstructor

type DriverConstructor func() driver.Driver

func GetDriver

func GetDriver(name string) (DriverConstructor, error)

type MigrationValueItem added in v4.2.3

type MigrationValueItem struct {
	MigrationValue, Value string
}

type ObjsUpdateHook

type ObjsUpdateHook = func(parent string, objs []model.Obj)

ObjsUpdateHook is a function type for hooks that process objects after they are updated

type SettingItemHook

type SettingItemHook func(item *model.SettingItem) error

SettingItemHook is a function type for hooks that process setting items

type StorageHook

type StorageHook func(typ string, storage driver.Driver)

StorageHook is a function type for hooks that process storage operations

Jump to

Keyboard shortcuts

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