MCPcopy Create free account
hub / github.com/isomorphic-git/isomorphic-git / writeObjectLoose

Function writeObjectLoose

src/storage/writeObjectLoose.js:3–15  ·  view source on GitHub ↗
({ fs, gitdir, object, format, oid })

Source from the content-addressed store, hash-verified

1import { InternalError } from '../errors/InternalError.js'
2
3export async function writeObjectLoose({ fs, gitdir, object, format, oid }) {
4 if (format !== 'deflated') {
5 throw new InternalError(
6 'GitObjectStoreLoose expects objects to write to be in deflated format'
7 )
8 }
9 const source = `objects/${oid.slice(0, 2)}/${oid.slice(2)}`
10 const filepath = `${gitdir}/${source}`
11 // Don't overwrite existing git objects - this helps avoid EPERM errors.
12 // Although I don't know how we'd fix corrupted objects then. Perhaps delete them
13 // on read?
14 if (!(await fs.exists(filepath))) await fs.write(filepath, object)
15}

Callers 1

_writeObjectFunction · 0.90

Calls 3

sliceMethod · 0.80
existsMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…