-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
nix flake: clarify error message when file is an unknown type #12167
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -200,7 +200,11 @@ std::optional<Mode> convertMode(SourceAccessor::Type type) | |||||
case SourceAccessor::tSymlink: return Mode::Symlink; | ||||||
case SourceAccessor::tRegular: return Mode::Regular; | ||||||
case SourceAccessor::tDirectory: return Mode::Directory; | ||||||
case SourceAccessor::tMisc: return std::nullopt; | ||||||
case SourceAccessor::tChar: | ||||||
case SourceAccessor::tBlock: | ||||||
case SourceAccessor::tSocket: | ||||||
case SourceAccessor::tFifo: return std::nullopt; | ||||||
case SourceAccessor::tUnknown: | ||||||
default: unreachable(); | ||||||
} | ||||||
} | ||||||
|
@@ -314,7 +318,11 @@ Mode dump( | |||||
return Mode::Symlink; | ||||||
} | ||||||
|
||||||
case SourceAccessor::tMisc: | ||||||
case SourceAccessor::tChar: | ||||||
case SourceAccessor::tBlock: | ||||||
case SourceAccessor::tSocket: | ||||||
case SourceAccessor::tFifo: | ||||||
case SourceAccessor::tUnknown: | ||||||
default: | ||||||
throw Error("file '%1%' has an unsupported type", path); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
This can use |
||||||
} | ||||||
|
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
|
@@ -5,6 +5,25 @@ namespace nix { | |||||||
|
||||||||
static std::atomic<size_t> nextNumber{0}; | ||||||||
|
||||||||
bool SourceAccessor::Stat::isTypeUnknown() { | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Formatting nitpick.
|
||||||||
return this->type != tRegular && this->type != tSymlink && this->type != tDirectory; | ||||||||
} | ||||||||
|
||||||||
std::string SourceAccessor::Stat::typeString() { | ||||||||
switch (this->type) { | ||||||||
case tRegular: return "regular"; | ||||||||
case tSymlink: return "symlink"; | ||||||||
case tDirectory: return "directory"; | ||||||||
case tChar: return "character device"; | ||||||||
case tBlock: return "block device"; | ||||||||
case tSocket: return "socket"; | ||||||||
case tFifo: return "fifo"; | ||||||||
case tUnknown: | ||||||||
default: return "unknown"; | ||||||||
} | ||||||||
return "unknown"; | ||||||||
} | ||||||||
|
||||||||
SourceAccessor::SourceAccessor() | ||||||||
: number(++nextNumber) | ||||||||
, displayPrefix{"«unknown»"} | ||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can just rely on the default case here (everything is unsupported except for the types handled above).