Skip to content

Commit

Permalink
fix ca creation for existing file (#360)
Browse files Browse the repository at this point in the history
if the target file already exists an arrors is reported, but the
file is deleted.
  • Loading branch information
mandelsoft authored May 12, 2023
1 parent 8b33f96 commit e2e0819
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
1 change: 0 additions & 1 deletion cmds/ocm/commands/ocmcmds/componentarchive/create/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,6 @@ func (o *Command) Run() error {
}
obj, err := comparch.Create(o.Context.OCMContext(), accessobj.ACC_CREATE, fp, mode, o.Handler, fs)
if err != nil {
fs.RemoveAll(fp)
return err
}
desc := obj.GetDescriptor()
Expand Down
7 changes: 6 additions & 1 deletion pkg/common/accessobj/format-directory.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,15 @@ func (_ DirectoryHandler) Create(info AccessObjectInfo, path string, opts access
}
rep, err := projectionfs.New(opts.GetPathFileSystem(), path)
if err != nil {
opts.GetPathFileSystem().RemoveAll(path)
return nil, errors.Wrapf(err, "unable to create projected filesystem from path %s", path)
}
opts.SetRepresentation(rep)
return NewAccessObject(info, ACC_CREATE, rep, nil, nil, mode)
obj, err := NewAccessObject(info, ACC_CREATE, rep, nil, nil, mode)
if err != nil {
opts.GetPathFileSystem().RemoveAll(path)
}
return obj, err
}

// WriteToFilesystem writes the current object to a filesystem.
Expand Down

0 comments on commit e2e0819

Please sign in to comment.