mirror of
https://github.com/restic/rest-server.git
synced 2025-12-07 09:36:13 -08:00
read support for length and offset
This commit is contained in:
21
context.go
21
context.go
@@ -1,6 +1,11 @@
|
||||
package main
|
||||
|
||||
import ()
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/restic/restic/backend"
|
||||
)
|
||||
|
||||
// A Context specifies the root directory where all repositories are stored
|
||||
type Context struct {
|
||||
@@ -8,10 +13,18 @@ type Context struct {
|
||||
}
|
||||
|
||||
func NewContext(path string) Context {
|
||||
return Context{path}
|
||||
return Context{filepath.Clean(path)}
|
||||
}
|
||||
|
||||
// Creates the file structure of the Context
|
||||
func (c *Context) Init() {
|
||||
|
||||
func (c *Context) Init() error {
|
||||
if _, err := os.Stat(c.path); err != nil {
|
||||
return os.MkdirAll(c.path, backend.Modes.Dir)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *Context) Repository(name string) (Repository, error) {
|
||||
name, err := ParseRepositoryName(name)
|
||||
return Repository{filepath.Join(c.path, name)}, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user