file

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2023 License: Apache-2.0 Imports: 27 Imported by: 1

Documentation

Index

Constants

View Source
const HLS_HEADER_FILENAME = "index.m3u8"
View Source
const HLS_SEGMENT_FILENAME = "%d.ts"
View Source
const TEMP_FOLDER = "tmp"

Variables

View Source
var HlsInfoMap = make(map[string]*HlsInfo)
View Source
var (

	// wait for the next request from client per message
	RpcWaitTimeout time.Duration
)

Functions

func CheckFileExisting

func CheckFileExisting(ctx context.Context, fileHash, fileName, savePath, encryptionTag, fileReqId string) bool

CheckFileExisting

func CheckFilePathEx

func CheckFilePathEx(fileHash, fileName, savePath string) bool

CheckFilePathEx

func CheckSliceExisting

func CheckSliceExisting(fileHash, fileName, sliceHash, savePath, fileReqId string) bool

CheckSliceExisting

func CleanFileHash added in v0.9.0

func CleanFileHash(key string)

CleanFileHash

func ClearFileMap

func ClearFileMap(hash string)

ClearFileMap

func CloseDownloadSession added in v0.9.0

func CloseDownloadSession(key string)

CloseDownloadSession

func DeleteDirectory

func DeleteDirectory(fileHash string)

DeleteDirectory DeleteDirectory

func DeleteSlice

func DeleteSlice(sliceHash string) error

DeleteSlice

func DeleteTmpFileSlices added in v0.8.0

func DeleteTmpFileSlices(ctx context.Context, fileHash string)

func DeleteTmpHlsFolder added in v0.8.0

func DeleteTmpHlsFolder(ctx context.Context, fileHash string)

func EscapePath

func EscapePath(param []string) string

EscapePath

func GetAllFiles

func GetAllFiles(pathname string)

GetAllFiles get all files in directory and all sub-directory recursively

func GetDownloadCsvPath

func GetDownloadCsvPath(fileHash, fileName, savePath string) string

GetDownloadCsvPath get download CSV path

func GetDownloadPath

func GetDownloadPath(fileName string) string

GetDownloadPath get download path

func GetDownloadTmpPath

func GetDownloadTmpPath(fileHash, fileName, savePath string) string

GetDownloadTmpPath get temporary download path

func GetDumpySliceData

func GetDumpySliceData(fileHash string, sliceNumber uint64) []byte

func GetFileData

func GetFileData(filePath string, offset *protos.SliceOffset) []byte

GetFileData

func GetFileHash

func GetFileHash(filePath, encryptionTag string) string

GetFileHash

func GetFileInfo

func GetFileInfo(filePath string) os.FileInfo

GetFileInfo

func GetFileListResult added in v0.9.0

func GetFileListResult(key string) (*rpc.FileListResult, bool)

GetFileListResult

func GetFilePath

func GetFilePath(hash string) string

GetFilePath

func GetFileShareResult added in v0.9.0

func GetFileShareResult(key string) (*rpc.FileShareResult, bool)

GetFileShareResult

func GetFileSuffix

func GetFileSuffix(fileName string) string

GetFileSuffix

func GetQueryOzoneResult added in v0.9.0

func GetQueryOzoneResult(key string) (*rpc.GetOzoneResult, bool)

GetQueryOzoneResult

func GetRemoteFileData added in v0.9.0

func GetRemoteFileData(hash string, offset *protos.SliceOffset) []byte

GetRemoteFileData application calls this func to fetch a (sub)slice of file data from remote user

func GetRemoteFileInfo added in v0.9.0

func GetRemoteFileInfo(key, reqId string) uint64

GetRemoteFileInfo

func GetRemoteFileSize added in v0.9.0

func GetRemoteFileSize(hash string) uint64

GetRemoteFileSize

func GetSignatureFromRemote added in v0.9.0

func GetSignatureFromRemote(key string) []byte

GetSignatureFromRemote

func GetSliceData

func GetSliceData(sliceHash string) []byte

GetSliceData

func GetSliceDataFromTmp added in v0.8.0

func GetSliceDataFromTmp(fileHash, sliceHash string) []byte

func GetSliceSize

func GetSliceSize(sliceHash string) int64

GetSliceSize

func GetVideoDuration

func GetVideoDuration(path string) (uint64, error)

func GetVideoTmpFolder

func GetVideoTmpFolder(fileHash string) string

func GetWholeFileData

func GetWholeFileData(filePath string) []byte

func IsFile

func IsFile(f string) (bool, error)

IsFile checks if the path is a file or directory

func IsFileRpcRemote added in v0.9.0

func IsFileRpcRemote(key string) bool

IsFileRpcRemote

func PathExists

func PathExists(path string) (bool, error)

pathExists

func RecordDownloadCSV

func RecordDownloadCSV(target *protos.RspFileStorageInfo)

RecordDownloadCSV

func SaveDownloadProgress

func SaveDownloadProgress(ctx context.Context, sliceHash, fileName, fileHash, savePath, fileReqId string)

SaveDownloadProgress

func SaveFileData

func SaveFileData(ctx context.Context, data []byte, offset int64, sliceHash, fileName, fileHash, savePath, fileReqId string) bool

SaveFileData

func SaveRemoteFileData added in v0.9.0

func SaveRemoteFileData(key string, data []byte, offset uint64) bool

SaveRemoteFileData application calls this func to send a slice of file data to remote user during download process

func SaveRemoteFileHash added in v0.9.0

func SaveRemoteFileHash(hash, fileName string, fileSize uint64)

SaveRemoteFileHash

func SaveSliceData

func SaveSliceData(data []byte, sliceHash string, offset uint64) bool

SaveSliceData

func SaveTmpSliceData added in v0.8.0

func SaveTmpSliceData(fileHash, sliceHash string, data []byte) error

func SendFileDataBack added in v0.9.0

func SendFileDataBack(hash string, content []byte)

SendFileDataBack rpc server feeds file data from remote user to application

func SetDownloadSliceDone added in v0.9.0

func SetDownloadSliceDone(key string)

SetDownloadSliceDone rpc server tells the remote user has received last downloaded slice

func SetFileListResult added in v0.9.0

func SetFileListResult(key string, result *rpc.FileListResult)

SetFileListResult

func SetFileShareResult added in v0.9.0

func SetFileShareResult(key string, result *rpc.FileShareResult)

SetFileShareResult

func SetQueryOzoneResult added in v0.9.0

func SetQueryOzoneResult(key string, result *rpc.GetOzoneResult)

SetQueryOzoneResult

func SetRemoteFileInfo added in v0.9.0

func SetRemoteFileInfo(key string, size uint64)

SetRemoteFileInfo

func SetRemoteFileResult added in v0.9.0

func SetRemoteFileResult(key string, result rpc.Result)

SetRemoteFileResult application sends the result of previous operation to rpc server

func SetSignature added in v0.9.0

func SetSignature(key string, sig []byte)

SetSignature

func SubscribeDownloadFileInfo added in v0.9.0

func SubscribeDownloadFileInfo(key string) chan uint64

func SubscribeDownloadSliceDone added in v0.9.0

func SubscribeDownloadSliceDone(key string) chan bool

SubscribeDownloadSliceDone

func SubscribeGetRemoteFileData added in v0.9.0

func SubscribeGetRemoteFileData(key string) chan []byte

SubscribeGetRemoteFileData application subscribes to remote file data and waits for remote user's feedback

func SubscribeGetSignature added in v0.9.0

func SubscribeGetSignature(key string) chan []byte

SubscribeGetSignature

func SubscribeRemoteFileEvent added in v0.9.0

func SubscribeRemoteFileEvent(key string) chan *rpc.Result

SubscribeRemoteFileEvent rpc server subscribes to events from application. Now, result of operation is the only event

func UnsubscribeDownloadFileInfo added in v0.9.0

func UnsubscribeDownloadFileInfo(key string)

UnsubscribeDownloadFileInfo

func UnsubscribeDownloadSliceDone added in v0.9.0

func UnsubscribeDownloadSliceDone(key string)

UnsubscribeDownloadSliceDone

func UnsubscribeGetRemoteFileData added in v0.9.0

func UnsubscribeGetRemoteFileData(key string)

UnsubscribeGetRemoteFileData unsubscribe after the application finishes receiving the slice of file data

func UnsubscribeGetSignature added in v0.9.0

func UnsubscribeGetSignature(key string)

UnsubscribeGetSignature

func UnsubscribeRemoteFileEvent added in v0.9.0

func UnsubscribeRemoteFileEvent(key string)

UnsubscribeRemoteFileEvent rpc server unsubscribes to event from application. Now, result of operation is the only event

func VideoToHls

func VideoToHls(ctx context.Context, fileHash string) bool

func WaitDownloadSliceDone added in v0.9.0

func WaitDownloadSliceDone(key string) bool

WaitDownloadSliceDone application waits for remote user to tell that the downloaded slice received

Types

type HlsInfo

type HlsInfo struct {
	FileHash         string
	HeaderFile       string
	StartSliceNumber uint64
	TotalSize        int64
	SegmentToSlice   map[string]uint64
	SliceToSegment   map[uint64]string
}

func GetHlsInfo

func GetHlsInfo(fileHash string, maxSliceCount uint64) (*HlsInfo, error)

func LoadHlsInfo

func LoadHlsInfo(fileHash, sliceHash, savePath string) *HlsInfo

Jump to

Keyboard shortcuts

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