local: avoid writing to content root on readonly store

A contentstore can be created on top of readonly path and
should not fail unless there is an attempt to write into it.

Currently this fails because new ingest directory is created
always, meaning for example that you can't create a store to
read blobs from OCI layout without it contaminating the OCI
layout files.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
This commit is contained in:
Tonis Tiigi
2024-10-24 17:26:23 -07:00
parent 5a2da171fb
commit 3cc2343de0
2 changed files with 26 additions and 12 deletions

View File

@@ -108,10 +108,6 @@ func TestContentWriter(t *testing.T) {
defer cleanup()
defer testutil.DumpDirOnFailure(t, tmpdir)
if _, err := os.Stat(filepath.Join(tmpdir, "ingest")); os.IsNotExist(err) {
t.Fatal("ingest dir should be created", err)
}
cw, err := cs.Writer(ctx, content.WithRef("myref"))
if err != nil {
t.Fatal(err)
@@ -120,6 +116,10 @@ func TestContentWriter(t *testing.T) {
t.Fatal(err)
}
if _, err := os.Stat(filepath.Join(tmpdir, "ingest")); os.IsNotExist(err) {
t.Fatal("ingest dir should be created", err)
}
// reopen, so we can test things
cw, err = cs.Writer(ctx, content.WithRef("myref"))
if err != nil {