init: 0.1.1
feat: login page && auth required todo: 断点上传
This commit is contained in:
@ -109,8 +109,12 @@ func (m *meta) Start(ctx context.Context) {
|
||||
for code, info := range m.m {
|
||||
if now.Sub(info.last) > 1*time.Minute {
|
||||
m.Lock()
|
||||
info.f.Close()
|
||||
os.RemoveAll(opt.FilePath(code))
|
||||
if err := info.f.Close(); err != nil {
|
||||
log.Warn("handler.Meta: [timer] close file failed, file = %s, err = %s", opt.FilePath(code), err.Error())
|
||||
}
|
||||
if err := os.RemoveAll(opt.FilePath(code)); err != nil {
|
||||
log.Warn("handler.Meta: [timer] remove file failed, file = %s, err = %s", opt.FilePath(code), err.Error())
|
||||
}
|
||||
delete(m.m, code)
|
||||
m.Unlock()
|
||||
log.Warn("MetaController: code timeout removed, code = %s", code)
|
||||
|
@ -50,6 +50,10 @@ func Fetch() nf.HandlerFunc {
|
||||
func ShareNew() nf.HandlerFunc {
|
||||
return func(c *nf.Ctx) error {
|
||||
|
||||
if opt.Cfg.Auth {
|
||||
return c.SendStatus(http.StatusUnauthorized)
|
||||
}
|
||||
|
||||
filename := strings.TrimSpace(c.Param("filename"))
|
||||
if filename == "" {
|
||||
return c.Status(http.StatusBadRequest).JSON(map[string]string{"msg": "filename required"})
|
||||
|
@ -4,6 +4,7 @@ type config struct {
|
||||
Debug bool
|
||||
Address string
|
||||
DataPath string
|
||||
Auth bool
|
||||
}
|
||||
|
||||
var (
|
||||
|
Reference in New Issue
Block a user