(ctx context.Context, storageObject string)
| 63 | } |
| 64 | |
| 65 | func (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 | |
| 89 | func (s storage) delete(ctx context.Context, container string, object string) (err error) { |
| 90 | path := fsObjectsToPath(container, object) |
no test coverage detected