Documentation
¶
Index ¶
Constants ¶
const ( // UnknownDesc the description of Unknown code UnknownDesc = "unknown" // SuccessDesc the description of Success code SuccessDesc = "success" // FailDesc the description of Fail code FailDesc = "fail" UnauthorizedDesc = "unauthorized" // NotFoundDesc the description of NotFound code NotFoundDesc = "not found" // NoPermissionDesc the description of NoPermission code NoPermissionDesc = "no permission" // ServerErrorDesc the description of ServerError code ServerErrorDesc = "server internal error" // AccessDenyDesc the description of AccessDeny code AccessDenyDesc = "access deny" // NotModifiedDesc the description of NotModified code NotModifiedDesc = "not modified" // ChunkNotModifiedDesc the description of ChunkNotModified code ChunkNotModifiedDesc = "chunk not modified" // ModifiedDesc the description of Modified code ModifiedDesc = "modified" // ChunkModifiedDesc the description of ChunkModified code ChunkModifiedDesc = "chunk modified" )
const ( // FsDir is dir, see FsDirValue FsDir = "dir" // FsSize file size, bytes FsSize = "size" // FsHash file hash value FsHash = "hash" // FsHashValues the hash value of the entire file and first chunk and some checkpoints FsHashValues = "hash_values" // FsCtime file creation time FsCtime = "ctime" // FsAtime file last access time FsAtime = "atime" // FsMtime file last modify time FsMtime = "mtime" // FsPath file path FsPath = "path" // FsNeedHash return file hash or not FsNeedHash = "need_hash" // FsNeedCheckpoint return file checkpoint hash or not FsNeedCheckpoint = "need_checkpoint" )
const ( // ParamValueTrue the parameter value means true ParamValueTrue = "1" // ParamValueFalse the parameter value means false ParamValueFalse = "0" // FsNeedHashValueTrue the optional value of the FsNeedHash parameter, that means let file server return file hash value FsNeedHashValueTrue = ParamValueTrue )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Chunk ¶ added in v0.3.4
type Chunk struct { // Offset the offset relative to the origin of the file // // The offset less than zero is invalid. // The offset equals zero means the first chunk or only one chunk. // The offset greater than zero means that have two chunks at least. Offset int64 `json:"offset"` // Hash calculate the file chunk hash value, if the path is a file Hash string `json:"hash"` // Size the size of file chunk for bytes Size int64 `json:"size"` }
Chunk the file chunk info that is used to upload the file
type Code ¶
type Code int
Code the status code info
const ( // Unknown the unknown status code Unknown Code = 0 // Success the success status code Success Code = 1 // Fail the standard fail status code Fail Code = -1 Unauthorized Code = -2 // NotFound the resource not found status code NotFound Code = -3 // NoPermission the no permission status code, the user is authorized but has no permission NoPermission Code = -4 // ServerError the server error status code ServerError Code = -5 // AccessDeny deny current access AccessDeny Code = -6 // NotModified the resource is not modified NotModified Code = -7 // ChunkNotModified the chunk is not modified ChunkNotModified Code = -8 // Modified the resource is modified Modified Code = -9 // ChunkModified the chunk is modified ChunkModified Code = -10 )
type Command ¶
type Command []byte
Command the server command
var ( // InfoCommand send the info command to get server info InfoCommand Command = []byte("info") // AuthCommand send the auth command with username and password to sign in the server AuthCommand Command = []byte("auth") // UnknownCommand unknown command UnknownCommand Command = []byte("unknown") )
type FileInfo ¶
type FileInfo struct { // Path the file path Path string `json:"path"` // IsDir is a dir the path IsDir FsDirValue `json:"is_dir"` // Size the size of path for bytes Size int64 `json:"size"` // Hash calculate the path hash value, if the path is a file Hash string `json:"hash"` // HashValues the hash value of the entire file and first chunk and some checkpoints HashValues hashutil.HashValues `json:"hash_values"` // CTime creation time, unix sec CTime int64 `json:"c_time"` // ATime last access time, unix sec ATime int64 `json:"a_time"` // MTime last modify time, unix sec MTime int64 `json:"m_time"` }
FileInfo the basic file info description
type FileServerInfo ¶
type FileServerInfo struct { Status // ServerAddr the server running address ServerAddr string `json:"server_addr"` // SourcePath the source base path of the file server SourcePath string `json:"source_path"` // DestPath the dest base path of the file server DestPath string `json:"dest_path"` // QueryAddr the query api address of the file server QueryAddr string `json:"query_addr"` // PushAddr the push api address of the file server PushAddr string `json:"push_addr"` }
FileServerInfo the file server basic info
type FsDirValue ¶
type FsDirValue int
FsDirValue the optional value of FsDir
const ( // FsIsDir current path is a dir FsIsDir FsDirValue = 1 // FsNotDir current path is not a dir FsNotDir FsDirValue = 0 // FsUnknown current path is unknown file type FsUnknown FsDirValue = -1 )
func ParseFsDirValue ¶
func ParseFsDirValue(isDir bool) FsDirValue
ParseFsDirValue parse boolean to FsDirValue
func (FsDirValue) Not ¶
func (v FsDirValue) Not(t string) bool
Not is current value not equal to dest
func (FsDirValue) String ¶
func (v FsDirValue) String() string
String parse the current value to string
type Message ¶ added in v0.3.0
type Message struct {
Data []byte
}
Message the file sync message
func NewMessage ¶ added in v0.3.0
NewMessage create an instance of Message
type Status ¶
type Status struct { // Code current status code Code Code `json:"code"` // Message current status code description Message string `json:"message"` // ApiType mark current api type ApiType ApiType `json:"api_type"` }
Status the api response status info
func FailStatus ¶
FailStatus create an instance of fail status with specified api type
func NoPermissionStatus ¶ added in v0.3.0
NoPermissionStatus create an instance of no permission status with specified api type
func SuccessStatus ¶
SuccessStatus create an instance of success status with specified api type
func UnauthorizedStatus ¶
UnauthorizedStatus create an instance of unauthorized status with specified api type