Media / foldkit-media/server

keepOrClaim

function · packages/media/src/server/fileStore.ts:165

function keepOrClaim(
  current: Option.Option<FileAsset>,
  submitted: FileAsset,
  owner: string,
): Effect.Effect<FileAsset, FileUnclaimed, FileStore>

The file a row should hold after a save: the one it holds already when the submitted key is that file's, so a re-save claims nothing, and otherwise the submitted key claimed for owner. The facts come from the server either way, never from the client. Call it after the write is authorized, so a refused write claims nothing.