2020-03-10 12:08:59 +00:00
|
|
|
package filecache
|
|
|
|
|
|
|
|
import (
|
|
|
|
"errors"
|
2020-03-11 22:46:45 +00:00
|
|
|
"fmt"
|
2020-03-10 12:08:59 +00:00
|
|
|
"io"
|
|
|
|
"net/http"
|
2020-03-11 22:46:45 +00:00
|
|
|
"os"
|
2020-03-10 12:08:59 +00:00
|
|
|
|
|
|
|
"gitlab.com/slon/shad-go/distbuild/pkg/build"
|
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
|
|
|
ErrNotFound = errors.New("file not found")
|
|
|
|
ErrWriteLocked = errors.New("file is locked for write")
|
|
|
|
ErrReadLocked = errors.New("file is locked for read")
|
|
|
|
)
|
|
|
|
|
|
|
|
type Cache struct {
|
2020-03-11 22:46:45 +00:00
|
|
|
rootDir string
|
2020-03-10 12:08:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func New(rootDir string) (*Cache, error) {
|
2020-03-11 22:46:45 +00:00
|
|
|
if err := os.MkdirAll(rootDir, 0777); err != nil {
|
|
|
|
return nil, fmt.Errorf("error creating filecache: %w", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
c := &Cache{rootDir: rootDir}
|
|
|
|
return c, nil
|
2020-03-10 12:08:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (c *Cache) Range(fileFn func(file build.ID) error) error {
|
|
|
|
panic("implement me")
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *Cache) Remove(file build.ID) error {
|
|
|
|
panic("implement me")
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *Cache) Write(file build.ID) (w io.WriteCloser, abort func(), err error) {
|
|
|
|
panic("implement me")
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *Cache) Get(file build.ID) (path string, unlock func(), err error) {
|
|
|
|
panic("implement me")
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewHandler(c *Cache) http.Handler {
|
|
|
|
panic("implement me")
|
|
|
|
}
|