diff options
| author | 2026-03-25 14:30:31 +0000 | |
|---|---|---|
| committer | 2026-03-25 14:30:31 +0000 | |
| commit | bfa0a3f5f18b752a6ebd3d5b37411c6871f7bb17 (patch) | |
| tree | 8ee2479273e2b34d284c30703c2be48efe197556 /objectstore/loose/paths.go | |
| parent | *: Resort import order (diff) | |
| signature | No signature | |
*: objectstore -> object/store
Diffstat (limited to 'objectstore/loose/paths.go')
| -rw-r--r-- | objectstore/loose/paths.go | 43 |
1 files changed, 0 insertions, 43 deletions
diff --git a/objectstore/loose/paths.go b/objectstore/loose/paths.go deleted file mode 100644 index ca15aa62..00000000 --- a/objectstore/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" - "codeberg.org/lindenii/furgit/objectstore" -) - -// 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("objectstore/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 objectstore.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, objectstore.ErrObjectNotFound - } - - return nil, err - } - - return file, nil -} |
