diff options
| author | 2026-03-27 09:08:40 +0000 | |
|---|---|---|
| committer | 2026-03-27 09:08:40 +0000 | |
| commit | d7e90798170265b37ea5f980f94ca310cfda3180 (patch) | |
| tree | 89921ca5cb6dd5aaefa3c0ae72352381261cb1e6 /object/storer/loose/paths.go | |
| parent | CONTRIBUTING: Fix submitting changes deadlines (diff) | |
| signature | No signature | |
object/store: Rename from object/storer
Diffstat (limited to 'object/storer/loose/paths.go')
| -rw-r--r-- | object/storer/loose/paths.go | 43 |
1 files changed, 0 insertions, 43 deletions
diff --git a/object/storer/loose/paths.go b/object/storer/loose/paths.go deleted file mode 100644 index 58ef6b8e..00000000 --- a/object/storer/loose/paths.go +++ /dev/null @@ -1,43 +0,0 @@ -package loose - -import ( - "errors" - "fmt" - "io/fs" - "os" - "path/filepath" - - objectid "codeberg.org/lindenii/furgit/object/id" - objectstorer "codeberg.org/lindenii/furgit/object/storer" -) - -// objectPath returns the loose object path for id relative to the objects root. -func (store *Store) objectPath(id objectid.ObjectID) (string, error) { - if id.Algorithm() != store.algo { - return "", fmt.Errorf("objectstorer/loose: object id algorithm mismatch: got %s want %s", id.Algorithm(), store.algo) - } - - hex := id.String() - - return filepath.Join(hex[:2], hex[2:]), nil -} - -// openObject opens the loose object file for id. -// Missing files cause objectstorer.ErrObjectNotFound. -func (store *Store) openObject(id objectid.ObjectID) (*os.File, error) { - relPath, err := store.objectPath(id) - if err != nil { - return nil, err - } - - file, err := store.root.Open(relPath) - if err != nil { - if errors.Is(err, fs.ErrNotExist) { - return nil, objectstorer.ErrObjectNotFound - } - - return nil, err - } - - return file, nil -} |
