Skip to content

Commit

Permalink
Register no-op archiver for bytestream URIs
Browse files Browse the repository at this point in the history
  • Loading branch information
mortenmj committed Oct 16, 2024
1 parent d0ff213 commit 1c22bd3
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
2 changes: 2 additions & 0 deletions cmd/bb_portal/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,9 @@ func configureBlobArchiving(blobArchiver processing.BlobMultiArchiver, archiveFo
fatal("failed to create blob archive folder", "folder", archiveFolder, "err", err)
}
localBlobArchiver := processing.NewLocalFileArchiver(archiveFolder)
noopArchiver := processing.NewNoopArchiver()
blobArchiver.RegisterArchiver("file", localBlobArchiver)
blobArchiver.RegisterArchiver("bytestream", noopArchiver)
}

func runWatcher(watcher *fsnotify.Watcher, client *ent.Client, bepFolder string, blobArchiver processing.BlobMultiArchiver) {
Expand Down
19 changes: 19 additions & 0 deletions pkg/processing/archive.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,3 +125,22 @@ func (lfa LocalFileArchiver) archiveBlob(blobURI detectors.BlobURI) (*ent.Blob,
ArchiveURL: destPath,
}, nil
}

// NoopArchiver is an archiver which does not archive blobs. This is useful in situations where
// it is desirable to register an archiver for some URI scheme, without archiving those blobs.
type NoopArchiver struct {
}

// NewNoopArchiver creates a new NoopArchiver
func NewNoopArchiver() NoopArchiver {
return NoopArchiver{}
}

// ArchiveBlob Archive Blob function.
func (na NoopArchiver) ArchiveBlob(_ context.Context, blobURI detectors.BlobURI) ent.Blob {
return ent.Blob{
URI: string(blobURI),
SizeBytes: 0,
ArchiveURL: "",
}
}

0 comments on commit 1c22bd3

Please sign in to comment.