Documentation
¶
Index ¶
- Constants
- Variables
- func CheckResourceNameInvalid(s string) bool
- func GrantUserPermissions(db db.TxHandler, userID int32, permissions UserPermissions) error
- func Initialize(db db.Handler, cfg Config) error
- func Is(err, target error) bool
- func NewError(httpStatus int, code, msg string) error
- func NewServerError(msg string) error
- func RemoveBookmark(db db.TxHandler, userID int32, id uuid.UUID) error
- func RevokeUserPermissions(db db.TxHandler, userID int32, permissions UserPermissions) error
- func TrashCompact(ctx context.Context, logger *zerolog.Logger, duration time.Duration)
- func UserEmailByID(db db.Handler, id int) (string, error)
- func UserHome(db db.Handler, email string) (pgtype.UUID, error)
- type Bookmark
- type Config
- type DiskUsageInfo
- type Error
- type FileSystem
- func (f *FileSystem) Copy(r Resource, target string, id uuid.UUID, recursive bool, ...) (Resource, bool, error)
- func (f *FileSystem) CreateFileByPath(path string, requestedID, versionID uuid.UUID, ...) (io.WriteCloser, error)
- func (f *FileSystem) CreateFileVersion(r Resource, versionID uuid.UUID) (io.WriteCloser, error)
- func (f FileSystem) CreateMount(path string, backend storage.Backend) error
- func (f *FileSystem) CreatePublink(r Resource, id, password string, expires pgtype.Timestamp, accessLimit int) error
- func (f *FileSystem) CreateResourceByPath(path string, requestedID uuid.UUID, dir, createParents bool, ...) (Resource, error)
- func (f *FileSystem) Delete(r Resource) (Resource, error)
- func (f *FileSystem) DeleteForever(r Resource) error
- func (f *FileSystem) DeleteResourceVersion(res Resource, versionID uuid.UUID) (Resource, error)
- func (f *FileSystem) DiskUsage(r Resource) (DiskUsageInfo, error)
- func (f *FileSystem) GetAllVersions(r Resource) ([]Version, error)
- func (f *FileSystem) GetAncestors(r Resource) ([]ResourceAncestor, error)
- func (f *FileSystem) GetImg(r Resource, versionIDStr string, resolution img.Res) (io.ReadCloser, error)
- func (f *FileSystem) GetPath(r Resource) (string, error)
- func (f *FileSystem) GetVersion(r Resource, versionIDStr string) (Version, error)
- func (f *FileSystem) ListPublinks(r Resource) ([]Publink, error)
- func (f *FileSystem) Move(r Resource, target string, conflictResolution ResourceBindConflictResolution) (Resource, bool, error)
- func (f *FileSystem) ReadDir(r Resource, recursive bool) ([]Resource, error)
- func (f *FileSystem) ReadDirExtended(r Resource, recursive, includeDeleted, orderByDepth bool) ([]Resource, error)
- func (f *FileSystem) ResourceByID(id uuid.UUID) (Resource, error)
- func (f *FileSystem) ResourceByPath(path string) (Resource, error)
- func (f *FileSystem) ResourceByPathWithRoot(path string) (Resource, error)
- func (f *FileSystem) RestoreDeleted(r Resource, parentPathOrUUID string, name string, autoRename bool) (res Resource, err error)
- func (f *FileSystem) Search(query string, includeDeleted bool) ([]Resource, error)
- func (f *FileSystem) TrashEmpty() error
- func (f *FileSystem) TrashList(cursor string, n uint) ([]Resource, string, error)
- func (f *FileSystem) TrashSummary() (int, int, error)
- func (f *FileSystem) UpdatePermissions(r Resource, user User, permission Permission) (res Resource, err error)
- func (f *FileSystem) Walk(r Resource, depth int, fn func(Resource, string) error) error
- type Permission
- type Publink
- type PublinksConfig
- type ReadFileSystem
- type Resource
- func (r Resource) Created() time.Time
- func (r Resource) Deleted() pgtype.Timestamp
- func (r Resource) Dir() bool
- func (r Resource) Grants() []byte
- func (r Resource) ID() uuid.UUID
- func (r Resource) InheritedPermissions() []byte
- func (r Resource) LatestVersion() VersionInfo
- func (r Resource) Links() []byte
- func (r Resource) Modified() time.Time
- func (r Resource) Name() string
- func (r Resource) Versions() []byte
- func (r Resource) VisibleParentID() pgtype.UUID
- type ResourceAncestor
- type ResourceBindConflictResolution
- type User
- func CreateUser(db db.TxHandler, email, name string, noCreateHome bool) (User, error)
- func ListUsers(db db.Handler, since int64) ([]User, error)
- func UpdateUserHome(db db.TxHandler, userID int32, home pgtype.UUID) (User, error)
- func UpdateUserName(db db.TxHandler, userID int32, name string) (User, error)
- func UserByEmail(db db.Handler, email string) (User, error)
- func UserByID(db db.Handler, userID int32) (User, error)
- type UserConfig
- type UserPermissions
- type Version
- type VersionInfo
Constants ¶
const ( ResourceBindConflictResolutionError = ResourceBindConflictResolution(0) // Error if exists ResourceBindConflictResolutionEnsure = ResourceBindConflictResolution(1) // Error if type mismatch ResourceBindConflictResolutionRename = ResourceBindConflictResolution(2) // Auto rename new resource ResourceBindConflictResolutionOverwrite = ResourceBindConflictResolution(3) // Delete existing resource only if type mismatch (preserves props) ResourceBindConflictResolutionDelete = ResourceBindConflictResolution(4) // Delete existing resource before creating )
const ( PermissionNone = Permission(0) PermissionRead = Permission(4) PermissionWrite = Permission(32) PermissionSU = Permission(-1) )
const ( PermissionUsersInvite = UserPermissions(0x10) PermissionUsersGrant = UserPermissions(0x20) PermissionFilesAll = UserPermissions(0x100) )
Variables ¶
var ( ErrIDConflict = NewError(http.StatusConflict, "id_conflict", "ID conflict detected. A previous attempt may have succeeded") ErrInsufficientPermissions = NewError(http.StatusForbidden, "insufficient_permissions", "Insufficient permissions") ErrInsufficientScope = NewError(http.StatusForbidden, "insufficient_scope", "Insufficient scope") ErrPreviewNotFound = NewError(http.StatusNotFound, "preview_not_found", "Unable to locate preview") ErrResourceNotFound = NewError(http.StatusNotFound, "resource_not_found", "No such file or directory") ErrResourceNotCollection = NewError(http.StatusMethodNotAllowed, "resource_not_collection", "Cannot add a member to a non-collection resource") ErrResourceCollection = NewError(http.StatusMethodNotAllowed, "resource_collection", "Cannot write contents to a collection resource") ErrResourcePathInvalid = NewError(http.StatusBadRequest, "resource_path_invalid", "Resource path is invalid") ErrResourceNameInvalid = NewError(http.StatusBadRequest, "resource_name_invalid", "Resource name is invalid") ErrResourceNameConflict = NewError(http.StatusPreconditionFailed, "resource_name_conflict", "Another resource with this name already exists") ErrResourceMoveTargetSubdirectory = NewError(http.StatusConflict, "move_target_subdirectory", "Cannot move a resource to its own subdirectory") ErrResourceCopyTargetSelf = NewError(http.StatusConflict, "copy_target_self", "Cannot overwrite a resource with itself") ErrResourceDeleted = NewError(http.StatusPreconditionFailed, "resource_deleted", "Resource is deleted") ErrParentNotFound = NewError(http.StatusConflict, "parent_not_found", "Parent not found") ErrParentDeleted = NewError(http.StatusConflict, "parent_deleted", "Parent deleted") ErrPublinkNameConflict = NewError(http.StatusPreconditionFailed, "publink_name_conflict", "Another public share with this name already exists") ErrVersionNotFound = NewError(http.StatusNotFound, "version_not_found", "Version Not Foud") ErrResourceVersionLatest = NewError(http.StatusPreconditionFailed, "resource_version_latest", "Cannot delete most recent version of a resource") )
var ErrUserNotFound = NewError(http.StatusNotFound, "user_not_found", "no such user")
Functions ¶
func GrantUserPermissions ¶
func GrantUserPermissions(db db.TxHandler, userID int32, permissions UserPermissions) error
func NewServerError ¶
func RevokeUserPermissions ¶
func RevokeUserPermissions(db db.TxHandler, userID int32, permissions UserPermissions) error
func TrashCompact ¶
Types ¶
type Bookmark ¶
func AddBookmark ¶
type Config ¶
type Config struct {
User UserConfig `koanf:"users"`
Publinks PublinksConfig `koanf:"publinks"`
Img img.Config `koanf:"img"`
}
type DiskUsageInfo ¶
type Error ¶
type FileSystem ¶
type FileSystem struct {
// contains filtered or unexported fields
}
func OpenFileSystem ¶
func OpenFileSystem(db db.Handler, pathRoot pgtype.UUID, userID int32, userPermissions UserPermissions, scopes []string) *FileSystem
func OpenSUFileSystem ¶
func OpenSUFileSystem(db db.Handler) *FileSystem
func (*FileSystem) Copy ¶
func (f *FileSystem) Copy(r Resource, target string, id uuid.UUID, recursive bool, conflictResolution ResourceBindConflictResolution) (Resource, bool, error)
func (*FileSystem) CreateFileByPath ¶
func (f *FileSystem) CreateFileByPath(path string, requestedID, versionID uuid.UUID, conflictResolution ResourceBindConflictResolution) (io.WriteCloser, error)
func (*FileSystem) CreateFileVersion ¶
func (f *FileSystem) CreateFileVersion(r Resource, versionID uuid.UUID) (io.WriteCloser, error)
func (FileSystem) CreateMount ¶
func (f FileSystem) CreateMount(path string, backend storage.Backend) error
func (*FileSystem) CreatePublink ¶
func (*FileSystem) CreateResourceByPath ¶
func (f *FileSystem) CreateResourceByPath(path string, requestedID uuid.UUID, dir, createParents bool, conflictResolution ResourceBindConflictResolution) (Resource, error)
func (*FileSystem) DeleteForever ¶
func (f *FileSystem) DeleteForever(r Resource) error
func (*FileSystem) DeleteResourceVersion ¶
func (*FileSystem) DiskUsage ¶
func (f *FileSystem) DiskUsage(r Resource) (DiskUsageInfo, error)
func (*FileSystem) GetAllVersions ¶
func (f *FileSystem) GetAllVersions(r Resource) ([]Version, error)
func (*FileSystem) GetAncestors ¶
func (f *FileSystem) GetAncestors(r Resource) ([]ResourceAncestor, error)
func (*FileSystem) GetImg ¶
func (f *FileSystem) GetImg(r Resource, versionIDStr string, resolution img.Res) (io.ReadCloser, error)
func (*FileSystem) GetVersion ¶
func (f *FileSystem) GetVersion(r Resource, versionIDStr string) (Version, error)
func (*FileSystem) ListPublinks ¶
func (f *FileSystem) ListPublinks(r Resource) ([]Publink, error)
func (*FileSystem) Move ¶
func (f *FileSystem) Move(r Resource, target string, conflictResolution ResourceBindConflictResolution) (Resource, bool, error)
func (*FileSystem) ReadDir ¶
func (f *FileSystem) ReadDir(r Resource, recursive bool) ([]Resource, error)
func (*FileSystem) ReadDirExtended ¶
func (f *FileSystem) ReadDirExtended(r Resource, recursive, includeDeleted, orderByDepth bool) ([]Resource, error)
func (*FileSystem) ResourceByID ¶
func (f *FileSystem) ResourceByID(id uuid.UUID) (Resource, error)
func (*FileSystem) ResourceByPath ¶
func (f *FileSystem) ResourceByPath(path string) (Resource, error)
ResourceByPath locates the resource at path.
An empty path or "/" will return the root resource.
A permission check will be performed to ensure that the FileSystem's User has read permissions on the resource. If not, then ErrResourceNotFound will be returned.
func (*FileSystem) ResourceByPathWithRoot ¶
func (f *FileSystem) ResourceByPathWithRoot(path string) (Resource, error)
ResourceByPathWithRoot locates the resource at path. path may begin with a "<uuid>:" prefix, which will traverse the path relative to that root instead of this FileSystem's default [PathRoot].
An empty path or "/" will return the root resource.
A permission check will be performed to ensure that the FileSystem's User has read permissions on the resource. If not, then ErrResourceNotFound will be returned.
func (*FileSystem) RestoreDeleted ¶
func (*FileSystem) Search ¶
func (f *FileSystem) Search(query string, includeDeleted bool) ([]Resource, error)
func (*FileSystem) TrashEmpty ¶
func (f *FileSystem) TrashEmpty() error
func (*FileSystem) TrashSummary ¶
func (f *FileSystem) TrashSummary() (int, int, error)
func (*FileSystem) UpdatePermissions ¶
func (f *FileSystem) UpdatePermissions(r Resource, user User, permission Permission) (res Resource, err error)
type Permission ¶
type Permission = int32
type PublinksConfig ¶
type ReadFileSystem ¶
type ReadFileSystem interface {
ResourceByPath(string) (Resource, error)
ReadDir(Resource, bool) ([]Resource, error)
GetVersion(Resource, string) (Version, error)
Walk(Resource, int, func(Resource, string) error) error
}
filesystem_readonly.go
type Resource ¶
type Resource struct {
// contains filtered or unexported fields
}
func (Resource) InheritedPermissions ¶
func (Resource) LatestVersion ¶
func (r Resource) LatestVersion() VersionInfo
func (Resource) VisibleParentID ¶
type ResourceAncestor ¶
type ResourceAncestor struct {
ID uuid.UUID
Name string
UserPermission Permission
}
type ResourceBindConflictResolution ¶
type ResourceBindConflictResolution int32
type UserConfig ¶
type UserConfig struct {
BaseDir string `koanf:"basedir"`
Permisison UserPermissions `koanf:"permission"`
}
type UserPermissions ¶
type UserPermissions = int32
type Version ¶
type Version struct {
VersionInfo
Storage string
}
type VersionInfo ¶
type VersionInfo struct {
ID uuid.UUID `json:"id"`
Created int `json:"created"`
Deleted int `json:"deleted,omitempty"`
Size int64 `json:"size"`
MimeType string `json:"mime_type"`
SHA256 string `json:"sha256"`
ImgRes uint8 `json:"imgres"`
}
VersionInfo represents a single version of a resource json tags are needed for unmarshalling the json object in sql queries
Source Files
¶
- config.go
- content_props.go
- core.go
- disk_usage.go
- errors.go
- filesystem.go
- filesystem_readonly.go
- mount.go
- publink.go
- resource.go
- resource_ancestors.go
- resource_copy_move.go
- resource_create.go
- resource_delete.go
- resource_locate.go
- resource_open.go
- resource_permissions.go
- resource_preview.go
- resource_publink.go
- resource_select_queries.go
- resource_versions.go
- search.go
- trash.go
- user.go
- user_bookmarks.go
- user_select.go
- user_shared.go
- user_update.go
- version.go