mirror of
https://github.com/GopeedLab/gopeed.git
synced 2026-11-09 10:00:27 +00:00
ci: build web
This commit is contained in:
1 parent
ff4e6f448c
commit
bf8e24a6af
13 files changed
+140
-74
No files matched your search
@@ -1,6 +1,7 @@
|
||||
package controller
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"os"
|
||||
"path/filepath"
|
||||
)
|
||||
@@ -11,11 +12,10 @@ type Controller interface {
|
||||
}
|
||||
|
||||
type DefaultController struct {
|
||||
Files map[string]*os.File
|
||||
}
|
||||
|
||||
func NewController() *DefaultController {
|
||||
return &DefaultController{Files: make(map[string]*os.File)}
|
||||
return &DefaultController{}
|
||||
}
|
||||
|
||||
func (c *DefaultController) Touch(name string, size int64) (file *os.File, err error) {
|
||||
@@ -24,15 +24,15 @@ func (c *DefaultController) Touch(name string, size int64) (file *os.File, err e
|
||||
return
|
||||
}
|
||||
file, err = os.Create(name)
|
||||
if err != nil && !errors.Is(err, os.ErrExist) {
|
||||
return
|
||||
}
|
||||
if size > 0 {
|
||||
err = os.Truncate(name, size)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
if err == nil {
|
||||
c.Files[name] = file
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user