File tree Expand file tree Collapse file tree 1 file changed +11
-7
lines changed Expand file tree Collapse file tree 1 file changed +11
-7
lines changed Original file line number Diff line number Diff line change @@ -82,18 +82,22 @@ def get_endpoint():
82
82
83
83
# see https://github.com/git-lfs/git-lfs/blob/310d1b4a7d01e8d9d884447df4635c7a9c7642c2/docs/api/basic-transfers.md
84
84
def get_locations (objects ):
85
+ ret = ["local" for _ in objects ]
85
86
endpoint = get_endpoint ()
86
87
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
+ }
88
97
req = urllib .request .Request (
89
98
f"{ endpoint .href } /objects/batch" ,
90
99
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" ),
97
101
)
98
102
with urllib .request .urlopen (req ) as resp :
99
103
data = json .load (resp )
You can’t perform that action at this time.
0 commit comments