mirror of
https://github.com/octoleo/restic.git
synced 2024-11-11 07:41:03 +00:00
simplified prefix removal, removed unnecessary if-else statements
This commit is contained in:
parent
16eeed2ad5
commit
02014be76c
@ -47,9 +47,7 @@ func ParseConfig(s string) (interface{}, error) {
|
|||||||
return nil, errors.New("azure: invalid format: bucket name or path not found")
|
return nil, errors.New("azure: invalid format: bucket name or path not found")
|
||||||
}
|
}
|
||||||
container, path := data[0], path.Clean(data[1])
|
container, path := data[0], path.Clean(data[1])
|
||||||
if strings.HasPrefix(path, "/") {
|
path = strings.TrimPrefix(path, "/")
|
||||||
path = path[1:]
|
|
||||||
}
|
|
||||||
cfg := NewConfig()
|
cfg := NewConfig()
|
||||||
cfg.Container = container
|
cfg.Container = container
|
||||||
cfg.Prefix = path
|
cfg.Prefix = path
|
||||||
|
@ -49,9 +49,7 @@ func ParseConfig(s string) (interface{}, error) {
|
|||||||
|
|
||||||
bucket, path := data[0], path.Clean(data[1])
|
bucket, path := data[0], path.Clean(data[1])
|
||||||
|
|
||||||
if strings.HasPrefix(path, "/") {
|
path = strings.TrimPrefix(path, "/")
|
||||||
path = path[1:]
|
|
||||||
}
|
|
||||||
|
|
||||||
cfg := NewConfig()
|
cfg := NewConfig()
|
||||||
cfg.Bucket = bucket
|
cfg.Bucket = bucket
|
||||||
|
6
internal/cache/cache.go
vendored
6
internal/cache/cache.go
vendored
@ -175,11 +175,7 @@ const MaxCacheAge = 30 * 24 * time.Hour
|
|||||||
|
|
||||||
func validCacheDirName(s string) bool {
|
func validCacheDirName(s string) bool {
|
||||||
r := regexp.MustCompile(`^[a-fA-F0-9]{64}$`)
|
r := regexp.MustCompile(`^[a-fA-F0-9]{64}$`)
|
||||||
if !r.MatchString(s) {
|
return r.MatchString(s)
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
return true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// listCacheDirs returns the list of cache directories.
|
// listCacheDirs returns the list of cache directories.
|
||||||
|
6
internal/cache/file.go
vendored
6
internal/cache/file.go
vendored
@ -214,9 +214,5 @@ func (c *Cache) Has(h restic.Handle) bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_, err := fs.Stat(c.filename(h))
|
_, err := fs.Stat(c.filename(h))
|
||||||
if err == nil {
|
return err == nil
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
return false
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user