0.2.9 - don't need fs

This commit is contained in:
Cat /dev/Nulo 2023-05-16 19:39:48 -03:00
parent d64787ddc3
commit d44e35d40e
2 changed files with 19 additions and 15 deletions

View file

@ -1,6 +1,6 @@
{
"name": "@nulo/isogit-lfs",
"version": "0.2.8",
"version": "0.2.9",
"description": "LFS helpers for Isomorphic Git",
"main": "dist/index.js",
"repository": "git@github.com:riboseinc/isogit-lfs.git",

View file

@ -28,12 +28,13 @@ function isValidLFSInfoResponseData(
* Uses already cached object, if size matches.
*/
export default async function downloadBlobFromPointer(
{ promises: fs }: PromiseFsClient,
fs: PromiseFsClient | null,
{ http: { request }, headers = {}, url, auth }: HTTPRequest,
{ info, objectPath }: Pointer
): Promise<Buffer> {
if (fs) {
try {
const cached = await fs.readFile(objectPath);
const cached = await fs?.promises.readFile(objectPath);
if (cached.byteLength === info.size) {
return cached;
}
@ -43,6 +44,7 @@ export default async function downloadBlobFromPointer(
throw e;
}
}
}
const authHeaders: Record<string, string> = auth ? getAuthHeader(auth) : {};
@ -99,10 +101,12 @@ export default async function downloadBlobFromPointer(
const blob = await bodyToBuffer(lfsObjectBody);
if (fs) {
// Write LFS cache for this object, if cache path is accessible.
if (await isWriteable({ promises: fs }, objectPath)) {
await fs.mkdir(path.dirname(objectPath), { recursive: true });
await fs.writeFile(objectPath, blob);
if (await isWriteable(fs, objectPath)) {
await fs.promises.mkdir(path.dirname(objectPath), { recursive: true });
await fs.promises.writeFile(objectPath, blob);
}
}
return blob;