Skip to content

Commit 54c9aea

Browse files
committed
Bazel: fix lfs lazy rule when all objects are local
1 parent 6233da3 commit 54c9aea

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

misc/bazel/internal/git_lfs_probe.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -82,18 +82,22 @@ def get_endpoint():
8282

8383
# see https://github.com/git-lfs/git-lfs/blob/310d1b4a7d01e8d9d884447df4635c7a9c7642c2/docs/api/basic-transfers.md
8484
def get_locations(objects):
85+
ret = ["local" for _ in objects]
8586
endpoint = get_endpoint()
8687
indexes = [i for i, o in enumerate(objects) if o]
87-
ret = ["local" for _ in objects]
88+
if not indexes:
89+
# all objects are local, do not send an empty request as that would be an error
90+
return ret
91+
data = {
92+
"operation": "download",
93+
"transfers": ["basic"],
94+
"objects": [objects[i] for i in indexes],
95+
"hash_algo": "sha256",
96+
}
8897
req = urllib.request.Request(
8998
f"{endpoint.href}/objects/batch",
9099
headers=endpoint.headers,
91-
data=json.dumps({
92-
"operation": "download",
93-
"transfers": ["basic"],
94-
"objects": [o for o in objects if o],
95-
"hash_algo": "sha256",
96-
}).encode("ascii"),
100+
data=json.dumps(data).encode("ascii"),
97101
)
98102
with urllib.request.urlopen(req) as resp:
99103
data = json.load(resp)

0 commit comments

Comments
 (0)