commonres

package
v0.0.0-...-4436486 Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2020 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CloneResourceRepo

func CloneResourceRepo(ctx context.Context, res, clone Resource) (vcs.VCS, *ign.ErrMsg)

CloneResourceRepo clones the VCS repository of a given resource. Returns the VCS respository of the clone.

func CreateResourceRepo

func CreateResourceRepo(ctx context.Context, res Resource, filesPath string) (vcs.VCS, *ign.ErrMsg)

CreateResourceRepo creates the VCS repository for a given resource Returns the created VCS repository.

func FileTree

func FileTree(ctx context.Context, res Resource, version string) (*fuel.FileTree, *ign.ErrMsg)

FileTree gets a the file tree of a versioned resource.

func GetFile

func GetFile(ctx context.Context, res Resource, path, version string) (*[]byte, int, *ign.ErrMsg)

GetFile returns the contents (bytes) of a resource file. Given version is considered. Returns the file's bytes and the resolved version of the resource.

func GetLatestVersion

func GetLatestVersion(ctx context.Context, res Resource) (int, error)

GetLatestVersion gets the latest version number of a file based resource.

func GetRevisionFromVersion

func GetRevisionFromVersion(ctx context.Context, res Resource,
	version string) (string, int, *ign.ErrMsg)

GetRevisionFromVersion finds the revision hash from a given resource version. Version 1 is the initial version of the resource when the repo was created or cloned. Returns the found revision, the resolved version or an error.

func GetThumbnails

func GetThumbnails(res Resource) (tbns []string, err error)

GetThumbnails returns a slice of urls pointing to the thumbnails.

func GetZip

func GetZip(ctx context.Context, res Resource, subfolder string, version string) (*string, int, *ign.ErrMsg)

GetZip returns a path to the existing resource zip for the given version. It creates the zip if it does not exist. subfolder arg is the resource type folder for the user (eg. models, worlds)

func QueryForResourceVisibility

func QueryForResourceVisibility(tx, q *gorm.DB, owner *string, user *users.User) *gorm.DB

QueryForResourceVisibility checks the relationship between requestor (user) and the resource owner to formulate a database query to determine whether a resource is visible to the user

func Remove

func Remove(tx *gorm.DB, res Resource, user string) *ign.ErrMsg

Remove removes a resource. The user argument is the requesting user. It is used to check if the user can perform the operation.

func ZipResourceTip

func ZipResourceTip(ctx context.Context, repo vcs.VCS, res Resource, subfolder string) (int64, *ign.ErrMsg)

ZipResourceTip creates a new zip file for the given resource. Returns the zip Filesize or an error. subfolder arg is the resource type folder for the user (eg. models, worlds)

Types

type Resource

type Resource interface {
	GetName() *string
	GetOwner() *string
	GetLocation() *string
	GetUUID() *string
}

Resource represents a resource with files (eg. model, world)

Jump to

Keyboard shortcuts

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