Skip to content

Commit efe5d34

Browse files
committed
gvfs: clear DIE_IF_CORRUPT in streaming incore fallback (#873)
The upstream refactoring in 4c89d31 (streaming: rely on object sources to create object stream, 2025-11-23) changed how istream_source() discovers objects. Previously, it called odb_read_object_info_extended() with flags=0 to locate the object, then tried the source-specific opener (e.g. open_istream_loose). If that failed (e.g. corrupt loose object), it fell back to open_istream_incore which re-read the object — by which time the read-object hook had already re-fetched a clean copy. After the refactoring, istream_source() iterates over sources directly. When a corrupt loose object is found, odb_source_loose_read_object_stream fails and the loop continues to the next source. When no source has the object, it falls through to open_istream_incore, which calls odb_read_object_info_extended with OBJECT_INFO_DIE_IF_CORRUPT. This encounters the same corrupt loose file still on disk and dies before the read-object hook gets a chance to re-download a clean replacement. Fix this by clearing OBJECT_INFO_DIE_IF_CORRUPT in open_istream_incore when GVFS_MISSING_OK is set, matching the existing pattern in odb_read_object. This fixes the GitCorruptObjectTests functional test failures (GitRequestsReplacementForAllNullObject, GitRequestsReplacementForObjectCorruptedWithBadData, GitRequestsReplacementForTruncatedObject) that appeared when upgrading from v2.50.1.vfs.0.1 to v2.53.0.vfs.0.0. This is a companion to #782 (which predates 4c89d31, though, therefore it is not _exactly_ an omission of that PR).
2 parents b36fad3 + 0fd48b3 commit efe5d34

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

odb/streaming.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#include "convert.h"
77
#include "environment.h"
88
#include "repository.h"
9+
#include "gvfs.h"
910
#include "odb.h"
1011
#include "odb/source.h"
1112
#include "odb/streaming.h"
@@ -157,13 +158,14 @@ static int open_istream_incore(struct odb_read_stream **out,
157158
.base.read = read_istream_incore,
158159
};
159160
struct odb_incore_read_stream *st;
161+
unsigned flags = gvfs_config_is_set(odb->repo, GVFS_MISSING_OK) ?
162+
0 : OBJECT_INFO_DIE_IF_CORRUPT;
160163
int ret;
161164

162165
oi.typep = &stream.base.type;
163166
oi.sizep = &stream.base.size;
164167
oi.contentp = (void **)&stream.buf;
165-
ret = odb_read_object_info_extended(odb, oid, &oi,
166-
OBJECT_INFO_DIE_IF_CORRUPT);
168+
ret = odb_read_object_info_extended(odb, oid, &oi, flags);
167169
if (ret)
168170
return ret;
169171

0 commit comments

Comments
 (0)