(fs, gitdir, dir, filepath, oid = null)
| 29 | |
| 30 | // make sure filepath, blob type and blob object (from loose objects) plus oid are in sync and valid |
| 31 | async function checkAndWriteBlob(fs, gitdir, dir, filepath, oid = null) { |
| 32 | const currentFilepath = join(dir, filepath) |
| 33 | const stats = await fs.lstat(currentFilepath) |
| 34 | if (!stats) throw new NotFoundError(currentFilepath) |
| 35 | if (stats.isDirectory()) |
| 36 | throw new InternalError( |
| 37 | `${currentFilepath}: file expected, but found directory` |
| 38 | ) |
| 39 | |
| 40 | // Look for it in the loose object directory. |
| 41 | const objContent = oid |
| 42 | ? await readObjectLoose({ fs, gitdir, oid }) |
| 43 | : undefined |
| 44 | let retOid = objContent ? oid : undefined |
| 45 | if (!objContent) { |
| 46 | await acquireLock({ fs, gitdir, currentFilepath }, async () => { |
| 47 | const object = stats.isSymbolicLink() |
| 48 | ? await fs.readlink(currentFilepath).then(posixifyPathBuffer) |
| 49 | : await fs.read(currentFilepath) |
| 50 | |
| 51 | if (object === null) throw new NotFoundError(currentFilepath) |
| 52 | |
| 53 | retOid = await _writeObject({ fs, gitdir, type: 'blob', object }) |
| 54 | }) |
| 55 | } |
| 56 | |
| 57 | return retOid |
| 58 | } |
| 59 | |
| 60 | async function processTreeEntries({ fs, dir, gitdir, entries }) { |
| 61 | // make sure each tree entry has valid oid |
no test coverage detected
searching dependent graphs…