database

package
v1.10.28 Latest Latest
Warning

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

Go to latest
Published: Dec 12, 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 GetDatasetFileInfo = func(datasetID, filePath string) (*FileInfo, error) {
	var (
		d     *FileInfo
		err   error
		count int
	)

	for count < dbRetryTimes {
		d, err = DB.getDatasetFileInfo(datasetID, filePath)
		if err != nil {
			count++

			continue
		}

		break
	}

	return d, err
}

GetDatasetFileInfo returns information on a file given a dataset ID and an upload file path

View Source
var GetDatasetInfo = func(datasetID string) (*DatasetInfo, error) {
	var (
		d     *DatasetInfo = nil
		err   error        = nil
		count int          = 0
	)

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

			continue
		}

		break
	}

	return d, err
}

GetDatasetInfo returns further information on a given `datasetID` as `*DatasetInfo`.

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 DatasetInfo added in v1.9.6

type DatasetInfo struct {
	DatasetID string `json:"datasetId"`
	CreatedAt string `json:"createdAt"`
}

type FileDownload

type FileDownload struct {
	ArchivePath       string
	ArchiveSize       int
	DecryptedSize     int
	DecryptedChecksum string
	LastModified      string
	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"`
	FilePath                  string `json:"filePath"`
	FileName                  string `json:"fileName"`
	FileSize                  int64  `json:"fileSize"`
	DecryptedFileSize         int64  `json:"decryptedFileSize"`
	DecryptedFileChecksum     string `json:"decryptedFileChecksum"`
	DecryptedFileChecksumType string `json:"decryptedFileChecksumType"`
	Status                    string `json:"fileStatus"`
	CreatedAt                 string `json:"createdAt"`
	LastModified              string `json:"lastModified"`
}

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