]> source.dussan.org Git - jgit.git/commitdiff
Merge branch 'stable-6.6' into stable-6.7 46/1176746/1
authorDariusz Luksza <dariusz.luksza@gmail.com>
Mon, 12 Feb 2024 09:56:36 +0000 (09:56 +0000)
committerDariusz Luksza <dariusz.luksza@gmail.com>
Mon, 12 Feb 2024 09:56:36 +0000 (09:56 +0000)
* stable-6.6:
  Improve handling of NFS stale handle errors
  Fix handling of missing pack index file
  Add tests for handling pack files removal during fetch

Change-Id: Ie00984319d68beeffcbdb6bb323fbeb94a118e5c

1  2 
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/Pack.java
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackIndex.java

index 90f9811679b3c296928fbef153fe205a8f590ee6,d6c25b25877058f0eb7f006996de2e81217744d1..4f1d3488446a2f500abc59132d0cf03e676e26d4
@@@ -63,7 -56,7 +63,8 @@@ import org.eclipse.jgit.lib.Config
  import org.eclipse.jgit.lib.Constants;
  import org.eclipse.jgit.lib.ObjectId;
  import org.eclipse.jgit.lib.ObjectLoader;
 +import org.eclipse.jgit.util.Hex;
+ import org.eclipse.jgit.util.FileUtils;
  import org.eclipse.jgit.util.LongList;
  import org.eclipse.jgit.util.NB;
  import org.eclipse.jgit.util.RawParseUtils;
@@@ -1140,25 -1129,35 +1146,35 @@@ public class Pack implements Iterable<P
                if (invalid || bitmapIdxFile == null) {
                        return null;
                }
 -              if (bitmapIdx == null) {
 -                      final PackBitmapIndex idx;
 -                      try {
 -                              idx = PackBitmapIndex.open(bitmapIdxFile, idx(),
 -                                              getReverseIdx());
 -                      } catch (FileNotFoundException e) {
 -                              // Once upon a time the bitmap or index files existed. Now one
 -                              // of them has been removed. Most likely an external gc has
 -                              // removed index, packfile or the bitmap
 -                              bitmapIdxFile = null;
 -                              return null;
 -                      } catch (IOException e) {
 -                              if (!FileUtils.isStaleFileHandleInCausalChain(e)) {
 -                                      throw e;
 -                              }
 -                              // Ignore NFS stale handle exception the same way as
 -                              // FileNotFoundException above.
 -                              bitmapIdxFile = null;
 -                              return null;
 -                      }
 -
 +              Optional<PackBitmapIndex> optional = bitmapIdx.getOptional();
 +              if (optional.isPresent()) {
 +                      return optional.get();
 +              }
 +              try {
 +                      PackBitmapIndex idx = PackBitmapIndex.open(bitmapIdxFile, idx(),
 +                                      getReverseIdx());
                        // At this point, idx() will have set packChecksum.
                        if (Arrays.equals(packChecksum, idx.packChecksum)) {
 -                              bitmapIdx = idx;
 -                      } else {
 -                              bitmapIdxFile = null;
 +                              bitmapIdx = optionally(idx);
 +                              return idx;
 +                      }
 +              } catch (FileNotFoundException e) {
-                       // Once upon a time this bitmap file existed. Now it
-                       // has been removed. Most likely an external gc  has
-                       // removed this packfile and the bitmap
++                      // Once upon a time the bitmap or index files existed. Now one
++                      // of them has been removed. Most likely an external gc has
++                      // removed index, packfile or the bitmap
++                      bitmapIdxFile = null;
++                      return null;
++              } catch (IOException e) {
++                      if (!FileUtils.isStaleFileHandleInCausalChain(e)) {
++                              throw e;
+                       }
++                      // Ignore NFS stale handle exception the same way as
++                      // FileNotFoundException above.
++                      bitmapIdxFile = null;
++                      return null;
                }
 -              return bitmapIdx;
 +              bitmapIdxFile = null;
 +              return null;
        }
  
        private synchronized PackReverseIndex getReverseIdx() throws IOException {