Documentation
¶
Index ¶
- Constants
- Variables
- func CronCollectTrashBin(ctx context.Context)
- func NewEntityRecycleRoutineTask(ctx context.Context) (queue.Task, error)
- func NewEntityRecycleRoutineTaskFromModel(task *ent.Task) queue.Task
- func NewExplicitEntityRecycleTaskFromModel(task *ent.Task) queue.Task
- func NewMediaMetaTaskFromModel(task *ent.Task) queue.Task
- func NewUploadSentinelCheckTaskFromModel(task *ent.Task) queue.Task
- func ViewerFromContext(ctx context.Context) *types.Viewer
- type Archiver
- type CreateShareArgs
- type DirectLink
- type EntityManagement
- type EntityRecycleRoutineTask
- type EntityRecycleRoutineTaskState
- type EntityUrl
- type EntityUrlCache
- type ExplicitEntityRecycleTask
- type ExplicitEntityRecycleTaskState
- type FileManager
- type FileOperation
- type FsManagement
- type GenerateThumbTask
- type GetEntityUrlArgs
- type ListArgs
- type MediaMetaTask
- type MediaMetaTaskState
- type RecycleError
- type ShareManagement
- type UploadManagement
- type UploadSentinelCheckTask
- type UploadSentinelCheckTaskState
- type ViewerCtx
- type ViewerSession
- type ViewerSessionCache
- type ViewerSessionCacheCtx
Constants ¶
const ( UploadSessionCachePrefix = "callback_" // Ctx key for upload session UploadSessionCtx = "uploadSession" )
const ( EntityUrlCacheKeyPrefix = "entity_url_" DownloadSentinelCachePrefix = "download_sentinel_" )
const (
MinimumTrashCollectBatch = 1000
)
const (
ViewerSessionCachePrefix = "viewer_session_"
)
Variables ¶
var (
ErrUnknownPolicyType = serializer.NewError(serializer.CodeInternalSetting, "Unknown policy type", nil)
)
Functions ¶
func CronCollectTrashBin ¶
CronCollectTrashBin walks through all files in trash bin and delete them if they are expired.
Types ¶
type DirectLink ¶
type EntityManagement ¶
type EntityManagement interface { // GetEntityUrls gets download urls of given entities, return URLs and the earliest expiry time GetEntityUrls(ctx context.Context, args []GetEntityUrlArgs, opts ...fs.Option) ([]EntityUrl, *time.Time, error) // GetUrlForRedirectedDirectLink gets redirected direct download link of given direct link GetUrlForRedirectedDirectLink(ctx context.Context, dl *ent.DirectLink, opts ...fs.Option) (string, *time.Time, error) // GetDirectLink gets permanent direct download link of given files GetDirectLink(ctx context.Context, urls ...*fs.URI) ([]DirectLink, error) // GetEntitySource gets source of given entity GetEntitySource(ctx context.Context, entityID int, opts ...fs.Option) (entitysource.EntitySource, error) // Thumbnail gets thumbnail entity of given file Thumbnail(ctx context.Context, uri *fs.URI) (entitysource.EntitySource, error) // SubmitAndAwaitThumbnailTask submits a thumbnail task and waits for result SubmitAndAwaitThumbnailTask(ctx context.Context, uri *fs.URI, ext string, entity fs.Entity) (fs.Entity, error) // SetCurrentVersion sets current version of given file SetCurrentVersion(ctx context.Context, path *fs.URI, version int) error // DeleteVersion deletes a version of given file DeleteVersion(ctx context.Context, path *fs.URI, version int) error // ExtractAndSaveMediaMeta extracts and saves media meta into file metadata of given file. ExtractAndSaveMediaMeta(ctx context.Context, uri *fs.URI, entityID int) error // RecycleEntities recycles a group of entities RecycleEntities(ctx context.Context, force bool, entityIDs ...int) error // ListPhysical lists physical files in a path ListPhysical(ctx context.Context, path string, policyID int, recursive bool, progress driver.ListProgressFunc) ([]fs.PhysicalObject, error) // ImportPhysical imports a physical file to a Cloudreve file ImportPhysical(ctx context.Context, dst *fs.URI, policyId int, src fs.PhysicalObject, completeHook bool) error }
type EntityRecycleRoutineTaskState ¶
type EntityRecycleRoutineTaskState struct {
Errors [][]RecycleError `json:"errors,omitempty"`
}
type EntityUrlCache ¶
type ExplicitEntityRecycleTaskState ¶
type ExplicitEntityRecycleTaskState struct { EntityIDs []int `json:"entity_ids,omitempty"` Errors [][]RecycleError `json:"errors,omitempty"` }
type FileManager ¶
type FileManager interface { fs.LockSystem FileOperation EntityManagement UploadManagement FsManagement ShareManagement Archiver // Recycle reset current FileManager object and put back to resource pool Recycle() }
func NewFileManager ¶
func NewFileManager(dep dependency.Dep, u *ent.User) FileManager
type FileOperation ¶
type FileOperation interface { // Get gets file object by given path Get(ctx context.Context, path *fs.URI, opts ...fs.Option) (fs.File, error) // List lists files under given path List(ctx context.Context, path *fs.URI, args *ListArgs) (fs.File, *fs.ListFileResult, error) // Create creates a file or directory Create(ctx context.Context, path *fs.URI, fileType types.FileType, opt ...fs.Option) (fs.File, error) // Rename renames a file or directory Rename(ctx context.Context, path *fs.URI, newName string) (fs.File, error) // Delete deletes a group of file or directory. UnlinkOnly indicates whether to delete file record in DB only. Delete(ctx context.Context, path []*fs.URI, opts ...fs.Option) error // Restore restores a group of files Restore(ctx context.Context, path ...*fs.URI) error // MoveOrCopy moves or copies a group of files MoveOrCopy(ctx context.Context, src []*fs.URI, dst *fs.URI, isCopy bool) error // Update puts file content. If given file does not exist, it will create a new one. Update(ctx context.Context, req *fs.UploadRequest, opts ...fs.Option) (fs.File, error) // Walk walks through given path Walk(ctx context.Context, path *fs.URI, depth int, f fs.WalkFunc, opts ...fs.Option) error // UpsertMedata update or insert metadata of given file PatchMedata(ctx context.Context, path []*fs.URI, data ...fs.MetadataPatch) error // CreateViewerSession creates a viewer session for given file CreateViewerSession(ctx context.Context, uri *fs.URI, version string, viewer *types.Viewer) (*ViewerSession, error) // TraverseFile traverses a file to its root file, return the file with linked root. TraverseFile(ctx context.Context, fileID int) (fs.File, error) }
type FsManagement ¶
type FsManagement interface { // most recent existing parent directory will be returned. SharedAddressTranslation(ctx context.Context, path *fs.URI, opts ...fs.Option) (fs.File, *fs.URI, error) // Capacity gets capacity of current file system Capacity(ctx context.Context) (*fs.Capacity, error) // CheckIfCapacityExceeded checks if given user's capacity exceeded, and send notification email CheckIfCapacityExceeded(ctx context.Context) error // LocalDriver gets local driver for operating local files. LocalDriver(policy *ent.StoragePolicy) driver.Handler // CastStoragePolicyOnSlave check if given storage policy need to be casted to another. // It is used on slave node, when local policy need to cast to remote policy; // Remote policy with same node ID can be casted to local policy. CastStoragePolicyOnSlave(ctx context.Context, policy *ent.StoragePolicy) *ent.StoragePolicy // GetStorageDriver gets storage driver for given policy GetStorageDriver(ctx context.Context, policy *ent.StoragePolicy) (driver.Handler, error) // PatchView patches the view setting of a file PatchView(ctx context.Context, uri *fs.URI, view *types.ExplorerView) error }
type GenerateThumbTask ¶
type GenerateThumbTask struct { *queue.InMemoryTask // contains filtered or unexported fields }
type GetEntityUrlArgs ¶
GetEntityUrlArgs single args to get entity url
type ListArgs ¶
type ListArgs struct { Page int PageSize int PageToken string Order string OrderDirection string // StreamResponseCallback is used for streamed list operation, e.g. searching files. // Whenever a new item is found, this callback will be called with the current item and the parent item. StreamResponseCallback func(fs.File, []fs.File) }
type MediaMetaTask ¶
type MediaMetaTaskState ¶
type RecycleError ¶
type ShareManagement ¶
type UploadManagement ¶
type UploadManagement interface { // CreateUploadSession creates a upload session for given upload request CreateUploadSession(ctx context.Context, req *fs.UploadRequest, opts ...fs.Option) (*fs.UploadCredential, error) // ConfirmUploadSession confirms whether upload session is valid for upload. ConfirmUploadSession(ctx context.Context, session *fs.UploadSession, chunkIndex int) (fs.File, error) // Upload uploads file data to storage Upload(ctx context.Context, req *fs.UploadRequest, policy *ent.StoragePolicy) error // CompleteUpload completes upload session and returns file object CompleteUpload(ctx context.Context, session *fs.UploadSession) (fs.File, error) // CancelUploadSession cancels upload session CancelUploadSession(ctx context.Context, path *fs.URI, sessionID string) error // OnUploadFailed should be called when an unmanaged upload failed before complete. OnUploadFailed(ctx context.Context, session *fs.UploadSession) // Similar to CompleteUpload, but does not create actual uplaod session in storage. PrepareUpload(ctx context.Context, req *fs.UploadRequest, opts ...fs.Option) (*fs.UploadSession, error) // PreValidateUpload pre-validates an upload request. PreValidateUpload(ctx context.Context, dst *fs.URI, files ...fs.PreValidateFile) error }
type UploadSentinelCheckTask ¶
Upload sentinel check task is used for compliant storage policy (COS, S3...), it will delete the marked entity. It is expected to be queued after upload session is created, and canceled after upload callback is completed. If this task is executed, it means the upload callback does not complete in time.
type UploadSentinelCheckTaskState ¶
type UploadSentinelCheckTaskState struct {
Session *fs.UploadSession `json:"session"`
}
Upload sentinel check task is used for compliant storage policy (COS, S3...), it will delete the marked entity. It is expected to be queued after upload session is created, and canceled after upload callback is completed. If this task is executed, it means the upload callback does not complete in time.
type ViewerSession ¶
type ViewerSessionCache ¶
type ViewerSessionCache struct { ID string Uri string UserID int FileID int ViewerID string Version string Token string }
func ViewerSessionFromContext ¶
func ViewerSessionFromContext(ctx context.Context) *ViewerSessionCache
type ViewerSessionCacheCtx ¶
type ViewerSessionCacheCtx struct{}