forked from pachyderm/pachyderm
/
pfs.go
75 lines (58 loc) · 1.93 KB
/
pfs.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
package pfs
import (
"fmt"
"github.com/pachyderm/pachyderm/src/client/pfs"
)
// ErrFileNotFound represents a file-not-found error.
type ErrFileNotFound struct {
File *pfs.File
}
// ErrRepoNotFound represents a repo-not-found error.
type ErrRepoNotFound struct {
Repo *pfs.Repo
}
// ErrRepoExists represents a repo-exists error.
type ErrRepoExists struct {
Repo *pfs.Repo
}
// ErrCommitNotFound represents a commit-not-found error.
type ErrCommitNotFound struct {
Commit *pfs.Commit
}
// ErrCommitExists represents an error where the commit already exists.
type ErrCommitExists struct {
Commit *pfs.Commit
}
// ErrCommitFinished represents an error where the commit has been finished.
type ErrCommitFinished struct {
Commit *pfs.Commit
}
// ErrParentCommitNotFound represents a parent-commit-not-found error.
type ErrParentCommitNotFound struct {
Commit *pfs.Commit
}
func (e ErrFileNotFound) Error() string {
return fmt.Sprintf("file %v not found in repo %v at commit %v", e.File.Path, e.File.Commit.Repo.Name, e.File.Commit.ID)
}
func (e ErrRepoNotFound) Error() string {
return fmt.Sprintf("repo %v not found", e.Repo.Name)
}
func (e ErrRepoExists) Error() string {
return fmt.Sprintf("repo %v already exists", e.Repo.Name)
}
func (e ErrCommitNotFound) Error() string {
return fmt.Sprintf("commit %v not found in repo %v", e.Commit.ID, e.Commit.Repo.Name)
}
func (e ErrCommitExists) Error() string {
return fmt.Sprintf("commit %v already exists in repo %v", e.Commit.ID, e.Commit.Repo.Name)
}
func (e ErrCommitFinished) Error() string {
return fmt.Sprintf("commit %v in repo %v has already finished", e.Commit.ID, e.Commit.Repo.Name)
}
func (e ErrParentCommitNotFound) Error() string {
return fmt.Sprintf("parent commit %v not found in repo %v", e.Commit.ID, e.Commit.Repo.Name)
}
// ByteRangeSize returns byteRange.Upper - byteRange.Lower.
func ByteRangeSize(byteRange *pfs.ByteRange) uint64 {
return byteRange.Upper - byteRange.Lower
}