Commit 832fce8
authored
🐛 Fix sha over deduplication (#22)
## What is this?
We now use the name + sha to consider what needs to be deduplicated.
---
This pull request introduces signature-based deduplication for
screenshot uploads, improving how the system checks for existing
screenshots by considering metadata such as browser and viewport
dimensions. The main changes update the API service and uploader logic
to support this new format, ensure backward compatibility, and add
related test coverage.
**Signature-based deduplication and API changes:**
* Updated `ApiService.checkShas` to accept either an array of SHA
strings (legacy) or an array of screenshot objects with metadata, and
dynamically build the request body for the `/api/sdk/check-shas`
endpoint.
* Improved error handling in `ApiService.checkShas` to extract SHA
values from either format for consistent fallback behavior.
* Modified screenshot upload flow in `ApiService` to use the new
signature-based format when checking for existing screenshots, including
passing metadata such as browser and viewport.
[[1]](diffhunk://#diff-35db277c4b1bd7577c6a6ae77fcb683696b154b2a93f8c7394f0cf1432a24e29L175-R220)
[[2]](diffhunk://#diff-35db277c4b1bd7577c6a6ae77fcb683696b154b2a93f8c7394f0cf1432a24e29L195-R233)
**Uploader logic enhancements:**
* Refactored `checkExistingFiles` in `uploader.js` to batch and send
screenshot objects with signature data (including browser and viewport)
for deduplication, and added a helper to extract browser names from
filenames.
[[1]](diffhunk://#diff-8648aa90df287bc3a7eaf07f6f8d9a0243f8b46a9972bb94da8ee68258b6113dL301-R325)
[[2]](diffhunk://#diff-8648aa90df287bc3a7eaf07f6f8d9a0243f8b46a9972bb94da8ee68258b6113dR345-R362)
**Test updates for new format:**
* Updated tests in `api-service.spec.js` to verify that requests use the
new screenshot object format, including correct metadata extraction and
fallback to defaults where necessary.
[[1]](diffhunk://#diff-b42eca429b3d40549b6623640c048c1af75c9bd57e15acd0abfcceda1211fdb2L136-R144)
[[2]](diffhunk://#diff-b42eca429b3d40549b6623640c048c1af75c9bd57e15acd0abfcceda1211fdb2L188-R204)
[[3]](diffhunk://#diff-b42eca429b3d40549b6623640c048c1af75c9bd57e15acd0abfcceda1211fdb2L242-R266)1 parent 784ca30 commit 832fce8
File tree
3 files changed
+107
-22
lines changed- src/services
- tests/services
3 files changed
+107
-22
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
126 | 126 | | |
127 | 127 | | |
128 | 128 | | |
129 | | - | |
| 129 | + | |
130 | 130 | | |
131 | 131 | | |
132 | 132 | | |
133 | 133 | | |
134 | 134 | | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
135 | 157 | | |
136 | 158 | | |
137 | 159 | | |
138 | | - | |
| 160 | + | |
139 | 161 | | |
140 | 162 | | |
141 | 163 | | |
| |||
144 | 166 | | |
145 | 167 | | |
146 | 168 | | |
147 | | - | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
148 | 175 | | |
149 | 176 | | |
150 | 177 | | |
| |||
172 | 199 | | |
173 | 200 | | |
174 | 201 | | |
175 | | - | |
| 202 | + | |
176 | 203 | | |
177 | 204 | | |
178 | | - | |
179 | | - | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
180 | 218 | | |
181 | 219 | | |
182 | | - | |
| 220 | + | |
183 | 221 | | |
184 | 222 | | |
185 | 223 | | |
| |||
192 | 230 | | |
193 | 231 | | |
194 | 232 | | |
195 | | - | |
| 233 | + | |
196 | 234 | | |
197 | 235 | | |
198 | 236 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
298 | 298 | | |
299 | 299 | | |
300 | 300 | | |
301 | | - | |
| 301 | + | |
302 | 302 | | |
303 | 303 | | |
304 | | - | |
305 | 304 | | |
306 | 305 | | |
307 | 306 | | |
308 | | - | |
309 | | - | |
| 307 | + | |
| 308 | + | |
310 | 309 | | |
311 | 310 | | |
312 | | - | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
313 | 323 | | |
314 | 324 | | |
315 | | - | |
316 | | - | |
317 | | - | |
318 | | - | |
319 | | - | |
320 | | - | |
| 325 | + | |
321 | 326 | | |
322 | 327 | | |
323 | 328 | | |
| |||
337 | 342 | | |
338 | 343 | | |
339 | 344 | | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
340 | 363 | | |
341 | 364 | | |
342 | 365 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
133 | 133 | | |
134 | 134 | | |
135 | 135 | | |
136 | | - | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
137 | 145 | | |
138 | 146 | | |
139 | 147 | | |
| |||
185 | 193 | | |
186 | 194 | | |
187 | 195 | | |
188 | | - | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
189 | 205 | | |
190 | 206 | | |
191 | 207 | | |
| |||
239 | 255 | | |
240 | 256 | | |
241 | 257 | | |
242 | | - | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
243 | 267 | | |
244 | 268 | | |
245 | 269 | | |
| |||
0 commit comments