feat(store): add TaskStore CRUD and batch query methods for files and blobs

This commit is contained in:
dailz
2026-04-15 21:30:51 +08:00
parent d46a784efb
commit acf8c1d62b
7 changed files with 520 additions and 0 deletions

View File

@@ -82,6 +82,15 @@ func (s *BlobStore) Delete(ctx context.Context, sha256 string) error {
return nil
}
func (s *BlobStore) GetBySHA256s(ctx context.Context, sha256s []string) ([]model.FileBlob, error) {
var blobs []model.FileBlob
if len(sha256s) == 0 {
return blobs, nil
}
err := s.db.WithContext(ctx).Where("sha256 IN ?", sha256s).Find(&blobs).Error
return blobs, err
}
// GetBySHA256ForUpdate returns the FileBlob with a SELECT ... FOR UPDATE lock.
// Returns (nil, nil) if not found.
func (s *BlobStore) GetBySHA256ForUpdate(ctx context.Context, tx *gorm.DB, sha256 string) (*model.FileBlob, error) {