@@ -231,7 +231,7 @@ public synchronized void cacheData(ExceptionalSupplier<CacheResult, IOException>
231231 String url = conn .getURL ().toString ();
232232 String lastModified = conn .getHeaderField ("Last-Modified" );
233233 CacheResult cacheResult = cacheSupplier .get ();
234- ETagItem eTagItem = new ETagItem (url , eTag , cacheResult .hash , Files .getLastModifiedTime (cacheResult .cachedFile ).toMillis (), lastModified );
234+ ETagItem eTagItem = new ETagItem (url , eTag , cacheResult .hash , Files .getLastModifiedTime (cacheResult .cachedFile ).toMillis (), lastModified , 0L );
235235 Lock writeLock = lock .writeLock ();
236236 writeLock .lock ();
237237 try {
@@ -325,19 +325,24 @@ private static final class ETagItem {
325325 @ SerializedName ("remote" )
326326 private final String remoteLastModified ;
327327
328+ // The `expires` field is not used in HMCL 3.6.x, but will be used in HMCL 3.7.x.
329+ // We backported this field to 3.6.x to avoid breaking the etag.json file created by newer HMCL versions.
330+ private final long expires ;
331+
328332 /**
329333 * For Gson.
330334 */
331335 public ETagItem () {
332- this (null , null , null , 0 , null );
336+ this (null , null , null , 0 , null , 0L );
333337 }
334338
335- public ETagItem (String url , String eTag , String hash , long localLastModified , String remoteLastModified ) {
339+ public ETagItem (String url , String eTag , String hash , long localLastModified , String remoteLastModified , long expires ) {
336340 this .url = url ;
337341 this .eTag = eTag ;
338342 this .hash = hash ;
339343 this .localLastModified = localLastModified ;
340344 this .remoteLastModified = remoteLastModified ;
345+ this .expires = expires ;
341346 }
342347
343348 public int compareTo (ETagItem other ) {
@@ -361,12 +366,13 @@ public boolean equals(Object o) {
361366 Objects .equals (url , eTagItem .url ) &&
362367 Objects .equals (eTag , eTagItem .eTag ) &&
363368 Objects .equals (hash , eTagItem .hash ) &&
364- Objects .equals (remoteLastModified , eTagItem .remoteLastModified );
369+ Objects .equals (remoteLastModified , eTagItem .remoteLastModified ) &&
370+ expires == eTagItem .expires ;
365371 }
366372
367373 @ Override
368374 public int hashCode () {
369- return Objects .hash (url , eTag , hash , localLastModified , remoteLastModified );
375+ return Objects .hash (url , eTag , hash , localLastModified , remoteLastModified , expires );
370376 }
371377 }
372378
0 commit comments