fix(docker): add dockfile and small fixes (#38)
* fix(docker): add dockfile and small fixes * chore(readme): small fixes
This commit is contained in:
parent
c8a3f911e8
commit
b0d1cdccfc
11 changed files with 126 additions and 36 deletions
|
@ -4,7 +4,8 @@
|
|||
"description": "web client for quickshare",
|
||||
"main": "",
|
||||
"scripts": {
|
||||
"build": "yarn prod:addjs && webpack --config webpack.app.prod.js",
|
||||
"build": "yarn prod:addjs && yarn build:prod:wp",
|
||||
"build:prod:wp": "webpack --config webpack.app.prod.js",
|
||||
"build:watch": "webpack --config webpack.app.prod.js --watch",
|
||||
"build:dev": "yarn dev:addjs && webpack --config webpack.app.dev.js --watch",
|
||||
"test": "jest test --maxWorkers=2",
|
||||
|
|
|
@ -46,6 +46,7 @@ type FileHandlers struct {
|
|||
|
||||
func NewFileHandlers(cfg gocfg.ICfg, deps *depidx.Deps) (*FileHandlers, error) {
|
||||
var err error
|
||||
|
||||
if err = deps.FS().MkdirAll(UploadDir); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -113,7 +114,7 @@ func (h *FileHandlers) Create(c *gin.Context) {
|
|||
}
|
||||
userName := c.MustGet(singleuserhdr.UserParam).(string)
|
||||
|
||||
tmpFilePath := getTmpPath(req.Path)
|
||||
tmpFilePath := h.getTmpPath(req.Path)
|
||||
locker := h.NewAutoLocker(c, lockName(userName, tmpFilePath))
|
||||
locker.Exec(func() {
|
||||
err := h.deps.FS().Create(tmpFilePath)
|
||||
|
@ -261,7 +262,7 @@ func (h *FileHandlers) UploadChunk(c *gin.Context) {
|
|||
}
|
||||
userName := c.MustGet(singleuserhdr.UserParam).(string)
|
||||
|
||||
tmpFilePath := getTmpPath(req.Path)
|
||||
tmpFilePath := h.getTmpPath(req.Path)
|
||||
locker := h.NewAutoLocker(c, lockName(userName, tmpFilePath))
|
||||
locker.Exec(func() {
|
||||
var err error
|
||||
|
@ -331,7 +332,7 @@ func (h *FileHandlers) UploadStatus(c *gin.Context) {
|
|||
}
|
||||
userName := c.MustGet(singleuserhdr.UserParam).(string)
|
||||
|
||||
tmpFilePath := getTmpPath(filePath)
|
||||
tmpFilePath := h.getTmpPath(filePath)
|
||||
locker := h.NewAutoLocker(c, lockName(userName, tmpFilePath))
|
||||
locker.Exec(func() {
|
||||
_, fileSize, uploaded, err := h.uploadMgr.GetInfo(userName, tmpFilePath)
|
||||
|
@ -468,7 +469,7 @@ func (h *FileHandlers) CopyDir(c *gin.Context) {
|
|||
c.JSON(q.NewMsgResp(501, "Not Implemented"))
|
||||
}
|
||||
|
||||
func getTmpPath(filePath string) string {
|
||||
func (h *FileHandlers) getTmpPath(filePath string) string {
|
||||
return path.Join(UploadDir, fmt.Sprintf("%x", sha1.Sum([]byte(filePath))))
|
||||
}
|
||||
|
||||
|
@ -504,7 +505,7 @@ func (h *FileHandlers) DelUploading(c *gin.Context) {
|
|||
userName := c.MustGet(singleuserhdr.UserParam).(string)
|
||||
|
||||
var err error
|
||||
tmpFilePath := getTmpPath(filePath)
|
||||
tmpFilePath := h.getTmpPath(filePath)
|
||||
locker := h.NewAutoLocker(c, lockName(userName, tmpFilePath))
|
||||
locker.Exec(func() {
|
||||
err = h.deps.FS().Remove(tmpFilePath)
|
||||
|
|
|
@ -9,33 +9,33 @@ type FSConfig struct {
|
|||
}
|
||||
|
||||
type UsersCfg struct {
|
||||
EnableAuth bool `json:"enableAuth"`
|
||||
DefaultAdmin string `json:"defaultAdmin" cfg:"env"`
|
||||
DefaultAdminPwd string `json:"defaultAdminPwd" cfg:"env"`
|
||||
CookieTTL int `json:"cookieTTL"`
|
||||
CookieSecure bool `json:"cookieSecure"`
|
||||
CookieHttpOnly bool `json:"cookieHttpOnly"`
|
||||
EnableAuth bool `json:"enableAuth" yaml:"enableAuth"`
|
||||
DefaultAdmin string `json:"defaultAdmin" yaml:"defaultAdmin" cfg:"env"`
|
||||
DefaultAdminPwd string `json:"defaultAdminPwd" yaml:"defaultAdminPwd" cfg:"env"`
|
||||
CookieTTL int `json:"cookieTTL" yaml:"cookieTTL"`
|
||||
CookieSecure bool `json:"cookieSecure" yaml:"cookieSecure"`
|
||||
CookieHttpOnly bool `json:"cookieHttpOnly" yaml:"cookieHttpOnly"`
|
||||
}
|
||||
|
||||
type Secrets struct {
|
||||
TokenSecret string `json:"tokenSecret" cfg:"env"`
|
||||
TokenSecret string `json:"tokenSecret" yaml:"tokenSecret" cfg:"env"`
|
||||
}
|
||||
|
||||
type ServerCfg struct {
|
||||
Debug bool `json:"debug"`
|
||||
Host string `json:"host"`
|
||||
Port int `json:"port"`
|
||||
ReadTimeout int `json:"readTimeout"`
|
||||
WriteTimeout int `json:"writeTimeout"`
|
||||
MaxHeaderBytes int `json:"maxHeaderBytes"`
|
||||
PublicPath string `json:"publicPath"`
|
||||
Debug bool `json:"debug" yaml:"debug"`
|
||||
Host string `json:"host" yaml:"host"`
|
||||
Port int `json:"port" yaml:"port"`
|
||||
ReadTimeout int `json:"readTimeout" yaml:"readTimeout"`
|
||||
WriteTimeout int `json:"writeTimeout" yaml:"writeTimeout"`
|
||||
MaxHeaderBytes int `json:"maxHeaderBytes" yaml:"maxHeaderBytes"`
|
||||
PublicPath string `json:"publicPath" yaml:"publicPath"`
|
||||
}
|
||||
|
||||
type Config struct {
|
||||
Fs *FSConfig `json:"fs"`
|
||||
Secrets *Secrets `json:"secrets"`
|
||||
Server *ServerCfg `json:"server"`
|
||||
Users *UsersCfg `json:"users"`
|
||||
Fs *FSConfig `json:"fs" yaml:"fs"`
|
||||
Secrets *Secrets `json:"secrets" yaml:"secrets"`
|
||||
Server *ServerCfg `json:"server" yaml:"server"`
|
||||
Users *UsersCfg `json:"users" yaml:"users"`
|
||||
}
|
||||
|
||||
func NewConfig() *Config {
|
||||
|
@ -45,7 +45,7 @@ func NewConfig() *Config {
|
|||
func DefaultConfig() (string, error) {
|
||||
defaultCfg := &Config{
|
||||
Fs: &FSConfig{
|
||||
Root: ".",
|
||||
Root: "root",
|
||||
OpensLimit: 128,
|
||||
OpenTTL: 60, // 1 min
|
||||
},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue