Explorer

definy.rename-uploads

description
The part uploads of renaming target to to_module.to_name: the target with its own references changed at the new name, the target removed at the old name, and the referrers with their references changed
type
Fn(
  target: @definy.snapshot-check-part,
  referrers: List<@definy.snapshot-check-part>,
  to_module: String,
  to_name: String,
  new_id: String
) -> Union{#ok(List<@definy.mcp-part-upload>), #error(String)}
expression
fn(target$0, referrers$1, to_module$2, to_name$3, new_id$4) =>
  @core.list-fold(
    T: @definy.snapshot-check-part,
    A: Union{#ok(List<@definy.mcp-part-upload>), #error(String)},
    reducer: fn(acc$7, item$8) =>
      match $7 {
        #error(message$9) =>
          #error($9),
        #ok(uploads$10) =>
          match @definy.renamed-content-item(part: $8, from: $0.id, to: $4) {
            #none(_) =>
              #error(@core.string-concat(left: "The content of the part could not be read: ", right: $8.name)),
            #some(item$11) =>
              #ok(@core.list-append(
                list: $10,
                item: @definy.mcp-part-upload-of(
                  module_name: $8.module_name,
                  name: @definy.part-bare-name(module_name: $8.module_name, name: $8.name),
                  content: #some($11)
                )
              ))
          }
      },
    init: match @definy.renamed-content-item(part: $0, from: $0.id, to: $4) {
      #none(_) =>
        #error(@core.string-concat(left: "The content of the part could not be read: ", right: $0.name)),
      #some(item$12) =>
        #ok([
          @definy.mcp-part-upload-of(module_name: $2, name: $3, content: #some($12)),
          @definy.mcp-part-upload-of(
            module_name: $0.module_name,
            name: @definy.part-bare-name(module_name: $0.module_name, name: $0.name),
            content: #none
          )
        ])
    },
    xs: $1
  )
visibility
public
definy.rename-uploads (project definy, branch main, snapshot l0VFjJZP174d8CbZWFoujAGTYjgsQu4uTq5uWCZaXgo)
id: 7KrBV1k89dSo2iWGSrSFai6jzPM62gz6O-dtcufTZEw
content hash: USNXya1Rwfgq-LhQMyhDmUOKaLshCwc42Ng3dfrePtk