MCPcopy Index your code
hub / github.com/SignTools/SignTools / createApp

Function createApp

src/storage/app.go:41–73  ·  view source on GitHub ↗
(unsignedFile io.Reader, name string, profile Profile, signArgs string, userBundleId string, builderId string, tweakMap map[string]io.Reader)

Source from the content-addressed store, hash-verified

39}
40
41func createApp(unsignedFile io.Reader, name string, profile Profile, signArgs string, userBundleId string, builderId string, tweakMap map[string]io.Reader) (App, error) {
42 app := newApp(uuid.NewString())
43 if err := os.MkdirAll(app.resolvePath(AppRoot), os.ModePerm); err != nil {
44 return nil, errors.New("make app dir")
45 }
46 pairs := map[FSName]string{
47 AppName: name,
48 AppSignArgs: signArgs,
49 AppUserBundleId: userBundleId,
50 AppBuilderId: builderId,
51 AppProfileId: profile.GetId(),
52 }
53 for fileType, value := range pairs {
54 if err := app.SetString(fileType, value); err != nil {
55 return nil, errors.WithMessagef(err, "set %s", fileType)
56 }
57 }
58 if err := app.SetFile(AppUnsignedFile, unsignedFile); err != nil {
59 return nil, errors.WithMessagef(err, "set %s", AppUnsignedFile)
60 }
61 if len(tweakMap) > 0 {
62 if err := app.MkDir(TweaksDir); err != nil {
63 return nil, err
64 }
65 }
66 for name, tweak := range tweakMap {
67 tweakPath := FSName(util.SafeJoinFilePaths(string(TweaksDir), name))
68 if err := app.SetFile(tweakPath, tweak); err != nil {
69 return nil, errors.WithMessagef(err, "set %s", tweakPath)
70 }
71 }
72 return app, nil
73}
74
75func newApp(id string) *app {
76 return &app{id: id, FileSystemBase: FileSystemBase{resolvePath: func(name FSName) string {

Callers 1

NewMethod · 0.85

Calls 8

SafeJoinFilePathsFunction · 0.92
newAppFunction · 0.85
FSNameTypeAlias · 0.85
NewMethod · 0.80
GetIdMethod · 0.65
SetStringMethod · 0.65
SetFileMethod · 0.65
MkDirMethod · 0.65

Tested by

no test coverage detected