database

package
v1.6.116 Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2023 License: AGPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CheckDataset = func(dataset string) (bool, error) {
	var (
		r     bool  = false
		err   error = nil
		count int   = 0
	)

	for count < dbRetryTimes {
		r, err = DB.checkDataset(dataset)
		if err != nil {
			count++

			continue
		}

		break
	}

	return r, err
}

CheckDataset checks if dataset name exists

View Source
var CheckFilePermission = func(fileID string) (string, error) {
	var (
		r     string = ""
		err   error  = nil
		count int    = 0
	)

	for count < dbRetryTimes {
		r, err = DB.checkFilePermission(fileID)
		if err != nil {
			count++

			continue
		}

		break
	}

	return r, err
}

CheckFilePermission checks if user has permissions to access the dataset the file is a part of

View Source
var GetFile = func(fileID string) (*FileDownload, error) {
	var (
		r     *FileDownload = nil
		err   error         = nil
		count int           = 0
	)
	for count < dbRetryTimes {
		r, err = DB.getFile(fileID)
		if err != nil {
			count++

			continue
		}

		break
	}

	return r, err
}

GetFile retrieves the file header

View Source
var GetFiles = func(datasetID string) ([]*FileInfo, error) {
	var (
		r     []*FileInfo = nil
		err   error       = nil
		count int         = 0
	)

	for count < dbRetryTimes {
		r, err = DB.getFiles(datasetID)
		if err != nil {
			count++

			continue
		}

		break
	}

	return r, err
}

GetFiles retrieves the file details

Functions

This section is empty.

Types

type FileDownload

type FileDownload struct {
	ArchivePath string
	ArchiveSize int
	Header      []byte
}

FileDownload details are used for downloading a file

type FileInfo

type FileInfo struct {
	FileID                    string `json:"fileId"`
	DatasetID                 string `json:"datasetId"`
	DisplayFileName           string `json:"displayFileName"`
	FileName                  string `json:"fileName"`
	FileSize                  int64  `json:"fileSize"`
	DecryptedFileSize         int64  `json:"decryptedFileSize"`
	DecryptedFileChecksum     string `json:"decryptedFileChecksum"`
	DecryptedFileChecksumType string `json:"decryptedFileChecksumType"`
	Status                    string `json:"fileStatus"`
}

FileInfo is returned by the metadata endpoint

type SQLdb

type SQLdb struct {
	DB       *sql.DB
	ConnInfo string
}

SQLdb struct that acts as a receiver for the DB update methods

var DB *SQLdb

DB is exported for other packages

func NewDB

func NewDB(config config.DatabaseConfig) (*SQLdb, error)

NewDB creates a new DB connection

func (*SQLdb) Close

func (dbs *SQLdb) Close()

Close terminates the connection to the database

Jump to

Keyboard shortcuts

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