# `MishkaCmsMigration.Resources.Changes.SourceFile`
[🔗](https://github.com/mishka-group/mishka_cms_migration/blob/v0.0.1/lib/mishka_cms_migration/resources/__changes/source_file.ex#L5)

The file a run of a source that reads one (`c:MishkaCmsMigration.Source.file?/0`) is handed,
kept from the run's creation until it ends (see "The source's file" in
`MishkaCmsMigration.MigrationRun`).

    create :create do
      argument :file, {:array, :map}
      change {MishkaCmsMigration.Resources.Changes.SourceFile, step: :take}
      change MishkaCmsMigration.Resources.Changes.CheckConnection
    end

    update :cancel do
      change {MishkaCmsMigration.Resources.Changes.SourceFile, step: :drop}
    end

`step: :take` drops a `"file"` the connection was typed with, and for a source that reads a file
takes the first entry of the `file` argument, Gervaz's upload entry, when it names a file Gervaz
staged (`MishkaCmsCore.Runtime.Media.staged_upload/2`; any other path, a symbolic link or a
folder, is not taken). The staged file's path is the connection's `"file"` while the run is
checked, so `CheckConnection` reads the source's host from it, and a `before_transaction` hook,
which runs before `CheckConnection`'s connect when it comes first in the action, copies it into
`files_dir/0` as `<uuid>.xml`, readable by the CMS's own user alone, and points `"file"` there.
An `after_transaction` hook deletes the copy when the run is not saved. A form only validating
what is typed has no upload, so nothing is copied until the run is created.

`step: :drop` deletes the run's file once the action has saved the run, and only a file straight
inside `files_dir/0`.

# `files_dir`

```elixir
@spec files_dir() :: Path.t()
```

The folder a run's file is kept in until the run ends: `mishka_cms_migration` under the
installer's project path (`MishkaInstaller.__information__/0`, the volume a host keeps its data
on, `MISHKA_DATA_DIR` in the CMS), or under the system's temporary folder on a node that names
none. Neither is a folder the CMS serves.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
