Skip to content

Commit

Permalink
Add version feature for tank cli.
Browse files Browse the repository at this point in the history
  • Loading branch information
zicla committed May 4, 2019
1 parent 5625149 commit 8dd524e
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 17 deletions.
25 changes: 11 additions & 14 deletions code/rest/matter_model.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,16 @@ const (
MATTER_ROOT = "root"
//cache directory name.
MATTER_CACHE = "cache"
//压缩文件的临时目录
MATTER_ZIP = "zip"
//matter名称最大长度
//zip file temp directory.
MATTER_ZIP = "zip"
MATTER_NAME_MAX_LENGTH = 200
//matter文件夹最大深度
MATTER_NAME_MAX_DEPTH = 32
MATTER_NAME_MAX_DEPTH = 32
//matter name pattern
MATTER_NAME_PATTERN = `[\\/:*?"<>|]`
)

/**
* 文件。
* file
*/
type Matter struct {
Base
Expand All @@ -45,17 +43,16 @@ func (Matter) TableName() string {
return core.TABLE_PREFIX + "matter"
}

// 获取该Matter的绝对路径。path代表的是相对路径。
// get matter's absolute path. the Path property is relative path in db.
func (this *Matter) AbsolutePath() string {
return GetUserFileRootDir(this.Username) + this.Path
return GetUserMatterRootDir(this.Username) + this.Path
}

// 获取该Matter的MimeType
func (this *Matter) MimeType() string {
return util.GetMimeType(util.GetExtension(this.Name))
}

//创建一个 ROOT 的matter,主要用于统一化处理移动复制等内容。
//Create a root matter. It's convenient for copy and move
func NewRootMatter(user *User) *Matter {
matter := &Matter{}
matter.Uuid = MATTER_ROOT
Expand All @@ -69,23 +66,23 @@ func NewRootMatter(user *User) *Matter {
return matter
}

//获取到用户文件的根目录。
func GetUserFileRootDir(username string) (rootDirPath string) {
//get user's root absolute path
func GetUserMatterRootDir(username string) (rootDirPath string) {

rootDirPath = fmt.Sprintf("%s/%s/%s", core.CONFIG.MatterPath(), username, MATTER_ROOT)

return rootDirPath
}

//获取到用户缓存的根目录。
//get user's cache absolute path
func GetUserCacheRootDir(username string) (rootDirPath string) {

rootDirPath = fmt.Sprintf("%s/%s/%s", core.CONFIG.MatterPath(), username, MATTER_CACHE)

return rootDirPath
}

//获取到用户压缩临时文件的根目录。
//get user's zip absolute path
func GetUserZipRootDir(username string) (rootDirPath string) {

rootDirPath = fmt.Sprintf("%s/%s/%s", core.CONFIG.MatterPath(), username, MATTER_ZIP)
Expand Down
2 changes: 1 addition & 1 deletion code/rest/matter_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ func (this *MatterService) createDirectory(request *http.Request, dirMatter *Mat
}

//绝对路径
absolutePath := GetUserFileRootDir(user.Username) + dirMatter.Path + "/" + name
absolutePath := GetUserMatterRootDir(user.Username) + dirMatter.Path + "/" + name

//相对路径
relativePath := dirMatter.Path + "/" + name
Expand Down
2 changes: 1 addition & 1 deletion code/rest/preference_dao.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func (this *PreferenceDao) Fetch() *Preference {
if db.Error != nil {

if db.Error.Error() == result.DB_ERROR_NOT_FOUND {
preference.Name = "蓝眼云盘"
preference.Name = "EyeblueTank"
preference.Version = core.VERSION
this.Create(preference)
return preference
Expand Down
14 changes: 13 additions & 1 deletion code/support/tank_application.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const (
MODE_MIRROR = "mirror"
//将远程的一个文件爬取到蓝眼云盘中
MODE_CRAWL = "crawl"
//TODO:查看当前蓝眼云盘版本
//TODO: 查看当前蓝眼云盘版本
MODE_VERSION = "version"
)

Expand Down Expand Up @@ -86,6 +86,11 @@ func (this *TankApplication) Start() {
//直接web启动
this.HandleWeb()

} else if strings.ToLower(this.mode) == MODE_VERSION {

//直接web启动
this.HandleVersion()

} else {

//准备蓝眼云盘地址
Expand Down Expand Up @@ -256,3 +261,10 @@ func (this *TankApplication) HandleCrawl() {
}

}

//fetch the application version
func (this *TankApplication) HandleVersion() {

fmt.Printf("EyeblueTank %s\r\n", core.VERSION)

}

0 comments on commit 8dd524e

Please sign in to comment.