MCPcopy Create free account
hub / github.com/bytebase/bytebase / HasSheets

Method HasSheets

backend/store/sheet.go:146–171  ·  view source on GitHub ↗

HasSheets checks if all sheets exist by SHA256 hashes.

(ctx context.Context, sha256Hexes ...string)

Source from the content-addressed store, hash-verified

144
145// HasSheets checks if all sheets exist by SHA256 hashes.
146func (s *Store) HasSheets(ctx context.Context, sha256Hexes ...string) (bool, error) {
147 if len(sha256Hexes) == 0 {
148 return true, nil
149 }
150
151 // Remove duplicates
152 sha256Hexes = common.Uniq(sha256Hexes)
153
154 q := qb.Q().Space(`
155 SELECT COUNT(*)
156 FROM sheet_blob
157 WHERE sha256 IN (SELECT decode(unnest(CAST(? AS TEXT[])), 'hex'))`,
158 sha256Hexes)
159
160 query, args, err := q.ToSQL()
161 if err != nil {
162 return false, errors.Wrapf(err, "failed to build sql")
163 }
164
165 var count int
166 if err := s.GetDB().QueryRowContext(ctx, query, args...).Scan(&count); err != nil {
167 return false, err
168 }
169
170 return count == len(sha256Hexes), nil
171}

Callers 3

CreateReleaseMethod · 0.80
createRevisionsMethod · 0.80
validateSpecsFunction · 0.80

Calls 6

GetDBMethod · 0.95
UniqFunction · 0.92
QFunction · 0.92
SpaceMethod · 0.80
ToSQLMethod · 0.80
ScanMethod · 0.80

Tested by

no test coverage detected