MCPcopy Create free account
hub / github.com/blues/note / createObject

Method createObject

lib/storage.go:65–87  ·  view source on GitHub ↗
(ctx context.Context, storageObject string)

Source from the content-addressed store, hash-verified

63}
64
65func (s storage) createObject(ctx context.Context, storageObject string) (err error) {
66 // Get the filename from the storage object name
67 name := fsRemoveScheme(storageObject)
68
69 // Create it (and overwrite it if it already exists), thus reserving it. In normal cases
70 // we don't try to create an object that already exists, and so the fact that we overwrite
71 // is simply defensive coding.
72 path := fsPath(name)
73 err = fio.Create(ctx, path)
74 if err != nil {
75 if deletionForbidden(ctx, path) {
76 return fmt.Errorf("file: can't re-create %s: %s", path, err)
77 }
78 _ = fio.Delete(ctx, path)
79 err = fio.Create(ctx, path)
80 if err != nil {
81 return
82 }
83 }
84
85 // Done
86 return nil
87}
88
89func (s storage) delete(ctx context.Context, container string, object string) (err error) {
90 path := fsObjectsToPath(container, object)

Callers 1

CreateNoteboxFunction · 0.80

Calls 5

fsRemoveSchemeFunction · 0.85
fsPathFunction · 0.85
deletionForbiddenFunction · 0.85
CreateMethod · 0.65
DeleteMethod · 0.65

Tested by

no test coverage detected