You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(dispatch): Abs paths on inputs to dispatch methods
Background: when `qri connect` is running, it holds an exclusive lock, and
other invocations of qri will send their commands to that connected process
using RPC. The two processes may be running in different directories, so it
is necessary to change file paths to be absolute before sending the params
across RPC. Before, we would do this explicitly, which was error-prone and
easy to forget about, since the broken behavior would not happen in the
common case.
The proposed solution implemented here adds tags to structs that are passed
to methods. Most use `qri:"fspath"` to specify fields that are file system
paths. Diff is special and uses `qri:"dsrefOrFspath"` because its inputs
can be either dsrefs or file paths. Adding this behavior for new commands
is simple; it just requires adding this tag.
An alternative would be to add a type for qfs.FilePath that does this
behavior itself. However, that requires users of qri to know about this type,
and FilePath types are typically quite tricky to fully implement. This
solution is simpler and adds less maintenance vs creating our own path type,
though it is admittedly a bit magical. Personally, I don't think it's that
bad, as it matches the standard use case of tags for serialization, if we
view fully absolute paths being sent over RPC as a type of data marshalling.
Plus, the Diff inputs act quite special. Simply creating a qfs.FilePath would
not be sufficient to handle Diff's parameters, and fixing Diff in some
way would probably add more complication than its worth.
0 commit comments