radicle-dev / radicle-link

The second iteration of the Radicle code collaboration protocol.
Other
421 stars 39 forks source link

profile: refactor Profile #717

Closed FintanH closed 3 years ago

FintanH commented 3 years ago

While scoping out the introduction of creating, getting, and setting profiles, I saw some room for refactoring to better see the flow of profile creation and loading.

This patch introduces the profile::id module which contains the ProfileId type. It surfaces the many ways to construct a ProfileId:

Before this change, a profile ID was simply a String, but now that it is behind a newtype wrapper, it's more obvious that it must go through validation during construction.

The other introduction to this change is the RadHome enum which captures where the Profile is living: XDG or some given Root.

The construction of a Profile is now computed in terms of RadHome and ProfileId.

Signed-off-by: Fintan Halpenny fintan.halpenny@gmail.com

FintanH commented 3 years ago

The only thing I'm not 100% convinced of is the naming XDG -- as a matter of fact, we are only adhering to XDG on Linux.

Good point, I think ProjectDirs is a better name because that's essentially what it's using in the end anyway.

See here for some reflections by the author of the directories crate.

Thanks for the link, that was enlightening :)

was it a mistake maybe to not just use XDG on all systems?

Are we not? :thinking: I was under the impression that using ProjectDirs does this, or maybe I'm misunderstanding your point?

xla commented 3 years ago

Discuss!

Adhering to the platforms prescribed default layouts has advantages like least surprise effect. It also should be to aid with packaging. Where it falls apart is when there is divergence as we experienced in the past with BIN_DIR and likely will encounter with the RUNTIME_DIR, both only covered by the XDG spec.

Are we not? thinking I was under the impression that using ProjectDirs does this, or maybe I'm misunderstanding your point?

It uses XDG on linux, Knwon Folders on Windows and Standard Directories on macOS.

kim commented 3 years ago

Knwon Folders