Documentation ¶
Index ¶
- Constants
- Variables
- func CacheRemoteFileData(fileHash string, offset *protos.SliceOffset, folderName, fileName string, ...) error
- func CheckDownloadCache(fileHash string) error
- func CheckFileExisting(ctx context.Context, ...) bool
- func CheckFilePathEx(filePath string) bool
- func CheckRemoteFileDownloadComplete(fileHash, reqid string, fileSize uint64) bool
- func CheckSliceExisting(fileHash, fileName, sliceHash, fileReqId string) bool
- func CleanFileHash(key string)
- func ClearFileMap(hash string)
- func CloseDownloadSession(key string)
- func CopyDownloadFile(fileHash, fileName, savePath string) error
- func CreateFolderAndReopenFile(folderPath, fileName string) (*os.File, error)
- func CreateTarWithZstd(source string, target string) error
- func DeleteDirectory(fileHash string)
- func DeleteSlice(sliceHash string) error
- func DeleteTmpFileSlices(ctx context.Context, fileHash string)
- func DeleteTmpHlsFolder(ctx context.Context, fileHash string)
- func EscapePath(param []string) string
- func ExtractTarWithZstd(source string, target string) error
- func FinishLocalDownload(fileHash string)
- func GetClearExpiredShareLinksResult(key string) (*rpc.ClearExpiredShareLinksResult, bool)
- func GetDownloadFileNameFromTmp(fileHash string) (string, error)
- func GetDownloadFilePath(fileName, savePath string) string
- func GetDownloadTmpCsvPath(fileHash, fileName string) string
- func GetDownloadTmpFilePath(fileHash, fileName string) string
- func GetDumpySliceData(fileHash string, sliceNumber uint64) []byte
- func GetFileData(filePath string, offset *protos.SliceOffset) ([]byte, error)
- func GetFileHash(filePath, encryptionTag string) string
- func GetFileHashForVideoStream(filePath, encryptionTag string) string
- func GetFileInfo(filePath string) (os.FileInfo, error)
- func GetFileListResult(key string) (*rpc.FileListResult, bool)
- func GetFileName(fileHash string) string
- func GetFilePath(hash string) string
- func GetFileSuffix(fileName string) string
- func GetQueryOzoneResult(key string) (*rpc.GetOzoneResult, bool)
- func GetRemoteFileInfo(key, reqId string) uint64
- func GetRemoteFileSize(hash string) uint64
- func GetSignatureFromRemote(key string) []byte
- func GetSliceData(sliceHash string) ([]byte, error)
- func GetSliceDataFromTmp(fileHash, sliceHash string) ([]byte, error)
- func GetSliceSize(sliceHash string) (int64, error)
- func GetTmpDownloadPath() string
- func GetTmpFileFolderPath(fileHash string) string
- func GetTmpSlicePath(fileHash, sliceHash string) string
- func GetVideoDuration(path string) (uint64, error)
- func GetVideoTmpFolder(fileHash string) string
- func GetWholeFileData(filePath string) ([]byte, error)
- func IsFile(f string) (bool, error)
- func IsFileRpcRemote(key string) bool
- func IsLocalDownload(fileHash string) bool
- func NextRemoteDownloadPacket(fileHash, reqid string) ([]byte, uint64, uint64, bool)
- func OpenTmpFile(fileHash, fileName string) (*os.File, error)
- func PathExists(path string) (bool, error)
- func ReadDownloadCachedData(fileHash, reqid string) ([]byte, uint64, uint64, bool)
- func ReadFileDataToPackets(r *mmap.ReaderAt, path string) (size int64, buffer [][]byte, err error)
- func ReadSliceData(fileHash, sliceHash string) (int64, [][]byte, error)
- func ReadSliceDataFromTmp(fileHash, sliceHash string) (int64, [][]byte, error)
- func RecordDownloadCSV(target *protos.RspFileStorageInfo)
- func RenameTmpFile(fileHash, srcFile, dstFile string) error
- func RequestBuffersForSlice(size int64) [][]byte
- func SaveDownloadProgress(ctx context.Context, sliceHash, fileName, fileHash, savePath, fileReqId string)
- func SaveDownloadedFileData(data []byte, offset int64, ...) error
- func SaveRemoteFileData(key, fileName string, data []byte, offset uint64) error
- func SaveRemoteFileHash(hash, filePath string, fileSize uint64)
- func SaveRemoteFileSliceData(sliceKey, fileKey, fileName string, data []byte, offset uint64) error
- func SaveRemoteSliceData(key, fileName string, data []byte, offset uint64) error
- func SaveSliceData(data []byte, sliceHash string, offset uint64) error
- func SaveTmpSliceData(fileHash, sliceHash string, data []byte) error
- func SendFileDataBack(hash string, content DataWithOffset)
- func SetClearExpiredShareLinksResult(key string, result *rpc.ClearExpiredShareLinksResult)
- func SetDownloadFileInfo(fileHash string, fileInfo DownloadFile)
- func SetDownloadSliceDone(key string)
- func SetDownloadSliceResult(fileHash string, result bool)
- func SetFileDeleteResult(key string, result *rpc.Result)
- func SetFileListResult(key string, result *rpc.FileListResult)
- func SetFileShareResult(key string, result *rpc.FileShareResult)
- func SetGetFileStatusDone(key string, result *rpc.FileStatusResult)
- func SetQueryOzoneResult(key string, result *rpc.GetOzoneResult)
- func SetRemoteFileInfo(key string, size uint64)
- func SetRemoteFileResult(key string, result rpc.Result) error
- func SetRemoteFileResultWithRetries(key string, result rpc.Result, interval time.Duration, retryTimes int)
- func SetRemoteSliceResult(key string, result rpc.Result)
- func SetSignature(key string, sig []byte)
- func StartClearTmpFileJob(ctx context.Context)
- func StartLocalDownload(fileHash string)
- func StopClearTmpFileJob()
- func SubscribeDownloadFileInfo(key string) chan uint64
- func SubscribeDownloadSlice(key string) chan bool
- func SubscribeDownloadSliceDone(key string) chan bool
- func SubscribeFileDeleteResult(fileHash string) chan *rpc.Result
- func SubscribeFileShareResult(shareLink string) chan *rpc.FileShareResult
- func SubscribeGetFileStatusDone(key string) chan *rpc.FileStatusResult
- func SubscribeGetRemoteFileData(key string) chan DataWithOffset
- func SubscribeGetSignature(key string) chan []byte
- func SubscribeRemoteFileEvent(key string) chan *rpc.Result
- func SubscribeRemoteSliceEvent(key string) chan *rpc.Result
- func UnsubscribeDownloadFileInfo(key string)
- func UnsubscribeDownloadSlice(key string)
- func UnsubscribeDownloadSliceDone(key string)
- func UnsubscribeFileDeleteResult(key string)
- func UnsubscribeFileShareResult(key string)
- func UnsubscribeGetFileStatusDone(key string)
- func UnsubscribeGetRemoteFileData(key string)
- func UnsubscribeGetSignature(key string)
- func UnsubscribeRemoteFileEvent(key string)
- func UnsubscribeRemoteSliceEvent(key string)
- func UpdateDownloadSlices(fileInfo DownloadFile, reqId string) (updated bool)
- func VideoToHls(ctx context.Context, fileHash, filePath string, sliceDuration int) bool
- func WaitDownloadSlice(fileHash, reqId string) bool
- func WaitDownloadSliceDone(key string) error
- func WriteFile(data []byte, offset int64, fileMg *os.File) error
- type DataWithOffset
- type DownloadFile
- type DownloadFileSlice
- type DownloadSlice
- type HlsInfo
Constants ¶
const (
DEFAULT_EXP_THRESHOLD = 2 // 2 days (will delete if no visit since 2 days ago)
)
const HLS_HEADER_FILENAME = "index.m3u8"
const HLS_SEGMENT_FILENAME = "%d.ts"
const (
LOCAL_TAG = "LOCAL"
)
const NUMBER_OF_UPLOAD_CHAN_BUFFER = 5
const TEMP_FOLDER = "tmp"
const TMP_FOLDER_VIDEO = "video"
Variables ¶
var (
DataBuffer sync.Mutex
)
var ( // wait for the next request from client per message RpcWaitTimeout time.Duration )
Functions ¶
func CacheRemoteFileData ¶ added in v0.10.0
func CheckDownloadCache ¶ added in v0.11.0
CheckDownloadCache check there is download cache for the file with fileHash
func CheckFileExisting ¶
func CheckFilePathEx ¶
func CheckRemoteFileDownloadComplete ¶ added in v0.12.0
func CheckSliceExisting ¶
func CleanFileHash ¶ added in v0.9.0
func CleanFileHash(key string)
func ClearFileMap ¶
func ClearFileMap(hash string)
func CloseDownloadSession ¶ added in v0.9.0
func CloseDownloadSession(key string)
func CopyDownloadFile ¶ added in v0.11.0
func CreateFolderAndReopenFile ¶ added in v0.11.0
func CreateTarWithZstd ¶ added in v0.10.0
func DeleteDirectory ¶
func DeleteDirectory(fileHash string)
func DeleteSlice ¶
func DeleteTmpFileSlices ¶ added in v0.8.0
func DeleteTmpHlsFolder ¶ added in v0.8.0
func ExtractTarWithZstd ¶ added in v0.10.0
func FinishLocalDownload ¶ added in v0.11.0
func FinishLocalDownload(fileHash string)
FinishLocalDownload when a local download is done, successfully or unsuccessfully, call this to untag
func GetClearExpiredShareLinksResult ¶ added in v0.10.0
func GetClearExpiredShareLinksResult(key string) (*rpc.ClearExpiredShareLinksResult, bool)
func GetDownloadFileNameFromTmp ¶ added in v0.11.0
GetDownloadFileNameFromTmp fetch the first name in download tmp folder with the filehash, and generate the file name
func GetDownloadFilePath ¶ added in v0.11.0
GetDownloadFilePath path to a file as in download folder
func GetDownloadTmpCsvPath ¶ added in v0.11.0
GetDownloadTmpCsvPath get download CSV path
func GetDownloadTmpFilePath ¶ added in v0.11.0
GetDownloadTmpFilePath path to the download tmp file
func GetDumpySliceData ¶
func GetFileData ¶
func GetFileData(filePath string, offset *protos.SliceOffset) ([]byte, error)
func GetFileHash ¶
func GetFileHashForVideoStream ¶ added in v0.10.0
func GetFileListResult ¶ added in v0.9.0
func GetFileListResult(key string) (*rpc.FileListResult, bool)
func GetFileName ¶ added in v0.11.0
func GetFilePath ¶
func GetFileSuffix ¶
func GetQueryOzoneResult ¶ added in v0.9.0
func GetQueryOzoneResult(key string) (*rpc.GetOzoneResult, bool)
func GetRemoteFileInfo ¶ added in v0.9.0
func GetRemoteFileSize ¶ added in v0.9.0
func GetSignatureFromRemote ¶ added in v0.9.0
func GetSliceData ¶
func GetSliceDataFromTmp ¶ added in v0.8.0
func GetSliceSize ¶
func GetTmpDownloadPath ¶ added in v0.11.0
func GetTmpDownloadPath() string
GetTmpDownloadPath path to the download tmp file folder
func GetTmpFileFolderPath ¶ added in v0.10.0
GetTmpFileFolderPath path to tmp file folder for specific file
func GetTmpSlicePath ¶ added in v0.10.0
func GetVideoDuration ¶
func GetVideoTmpFolder ¶
func GetWholeFileData ¶
func IsFileRpcRemote ¶ added in v0.9.0
func IsLocalDownload ¶ added in v0.11.0
StartLocalDownload when a local download starts, call this to tag a local download is on
func NextRemoteDownloadPacket ¶ added in v0.12.0
func ReadDownloadCachedData ¶ added in v0.11.0
ReadDownloadCachedData read setting.MacData bytes from the cache and store the cursor for next reading; check the end if cursor equals file size.
func ReadFileDataToPackets ¶ added in v0.10.1
func ReadSliceData ¶ added in v0.10.1
func ReadSliceDataFromTmp ¶ added in v0.10.1
func RecordDownloadCSV ¶
func RecordDownloadCSV(target *protos.RspFileStorageInfo)
func RenameTmpFile ¶ added in v0.10.0
func RequestBuffersForSlice ¶ added in v0.10.1
func SaveDownloadProgress ¶
func SaveDownloadedFileData ¶ added in v0.11.0
func SaveDownloadedFileData(data []byte, offset int64, sliceHash, fileName, fileHash, savePath, fileReqId string) error
SaveDownloadedFileData save data of downloaded file into download temporary folder
func SaveRemoteFileData ¶ added in v0.9.0
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 SaveRemoteFileSliceData ¶ added in v0.10.0
func SaveRemoteSliceData ¶ added in v0.10.0
SaveRemoteSliceData application calls this func to send a slice of file data to remote user during slice download process
func SaveTmpSliceData ¶ added in v0.8.0
func SendFileDataBack ¶ added in v0.9.0
func SendFileDataBack(hash string, content DataWithOffset)
SendFileDataBack rpc server feeds file data from remote user to application
func SetClearExpiredShareLinksResult ¶ added in v0.10.0
func SetClearExpiredShareLinksResult(key string, result *rpc.ClearExpiredShareLinksResult)
func SetDownloadFileInfo ¶ added in v0.12.0
func SetDownloadFileInfo(fileHash string, fileInfo DownloadFile)
func SetDownloadSliceDone ¶ added in v0.9.0
func SetDownloadSliceDone(key string)
SetDownloadSliceDone rpc server tells the remote user has received last downloaded slice
func SetDownloadSliceResult ¶ added in v0.12.0
func SetFileDeleteResult ¶ added in v0.12.3
func SetFileListResult ¶ added in v0.9.0
func SetFileListResult(key string, result *rpc.FileListResult)
func SetFileShareResult ¶ added in v0.9.0
func SetFileShareResult(key string, result *rpc.FileShareResult)
func SetGetFileStatusDone ¶ added in v0.10.0
func SetGetFileStatusDone(key string, result *rpc.FileStatusResult)
func SetQueryOzoneResult ¶ added in v0.9.0
func SetQueryOzoneResult(key string, result *rpc.GetOzoneResult)
func SetRemoteFileInfo ¶ added in v0.9.0
func SetRemoteFileResult ¶ added in v0.9.0
SetRemoteFileResult application sends the result of previous operation to rpc server
func SetRemoteFileResultWithRetries ¶ added in v0.12.0
func SetRemoteFileResultWithRetries(key string, result rpc.Result, interval time.Duration, retryTimes int)
SetRemoteFileResultWithRetries
func SetRemoteSliceResult ¶ added in v0.10.0
SetRemoteSliceResult application sends the result to rpc server
func SetSignature ¶ added in v0.9.0
func StartClearTmpFileJob ¶ added in v0.10.1
func StartLocalDownload ¶ added in v0.11.0
func StartLocalDownload(fileHash string)
StartLocalDownload when a local download starts, call this to tag a local download is on
func StopClearTmpFileJob ¶ added in v0.10.1
func StopClearTmpFileJob()
func SubscribeDownloadFileInfo ¶ added in v0.9.0
func SubscribeDownloadSlice ¶ added in v0.12.0
func SubscribeDownloadSliceDone ¶ added in v0.9.0
func SubscribeFileDeleteResult ¶ added in v0.12.3
func SubscribeFileShareResult ¶ added in v0.12.0
func SubscribeFileShareResult(shareLink string) chan *rpc.FileShareResult
func SubscribeGetFileStatusDone ¶ added in v0.10.0
func SubscribeGetFileStatusDone(key string) chan *rpc.FileStatusResult
func SubscribeGetRemoteFileData ¶ added in v0.9.0
func SubscribeGetRemoteFileData(key string) chan DataWithOffset
SubscribeGetRemoteFileData application subscribes to remote file data and waits for remote user's feedback
func SubscribeGetSignature ¶ added in v0.9.0
func SubscribeRemoteFileEvent ¶ added in v0.9.0
SubscribeRemoteFileEvent rpc server subscribes to events from application. Now, result of operation is the only event
func SubscribeRemoteSliceEvent ¶ added in v0.10.0
SubscribeRemoteSliceEvent 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)
func UnsubscribeDownloadSlice ¶ added in v0.12.0
func UnsubscribeDownloadSlice(key string)
func UnsubscribeDownloadSliceDone ¶ added in v0.9.0
func UnsubscribeDownloadSliceDone(key string)
func UnsubscribeFileDeleteResult ¶ added in v0.12.3
func UnsubscribeFileDeleteResult(key string)
func UnsubscribeFileShareResult ¶ added in v0.12.0
func UnsubscribeFileShareResult(key string)
func UnsubscribeGetFileStatusDone ¶ added in v0.10.0
func UnsubscribeGetFileStatusDone(key string)
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)
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 UnsubscribeRemoteSliceEvent ¶ added in v0.10.0
func UnsubscribeRemoteSliceEvent(key string)
UnsubscribeRemoteSliceEvent rpc server unsubscribes to event from application. Now, result of operation is the only event
func UpdateDownloadSlices ¶ added in v0.12.0
func UpdateDownloadSlices(fileInfo DownloadFile, reqId string) (updated bool)
func VideoToHls ¶
func WaitDownloadSlice ¶ added in v0.12.0
func WaitDownloadSliceDone ¶ added in v0.9.0
WaitDownloadSliceDone application waits for remote user to tell that the downloaded slice received
Types ¶
type DataWithOffset ¶ added in v0.12.0
type DownloadFile ¶ added in v0.12.0
type DownloadFile struct { FileHash string FileSize uint64 FileName string Slices []DownloadSlice }
type DownloadFileSlice ¶ added in v0.12.0
type DownloadFileSlice struct { CurrentSlice *DownloadSlice CurrentSliceOffset uint64 SlicesToDownload []*DownloadSlice }