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 99e18a9
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
4 changes: 4 additions & 0 deletions cmd/bb_portal/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,12 @@ func configureBlobArchiving(blobArchiver processing.BlobMultiArchiver, archiveFo
if err != nil {
fatal("failed to create blob archive folder", "folder", archiveFolder, "err", err)
}

localBlobArchiver := processing.NewLocalFileArchiver(archiveFolder)
blobArchiver.RegisterArchiver("file", localBlobArchiver)

noopArchiver := processing.NewNoopArchiver()
blobArchiver.RegisterArchiver("bytestream", noopArchiver)
}

func runWatcher(watcher *fsnotify.Watcher, client *ent.Client, bepFolder string, blobArchiver processing.BlobMultiArchiver) {
Expand Down
18 changes: 18 additions & 0 deletions pkg/processing/archive.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,3 +125,21 @@ 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 99e18a9

Please sign in to comment.