-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
allow disabling file detections by reading header #1175
Conversation
This is actually a duplicate of #1168 |
but that pr doesn't have the updated vue ui, no option exposed yet |
I don't think that we need any ui for that. Configuring this option per user doesn't make sense. |
Perhaps this can be made in a global option, the one that uses commandline to set options. An array of relatives path to root, that skips type detection. I tried the other pr. Mostly it works fine, however I have a directory full of subtitle files (sass extension), the mime type detection fails, directory become very slow to show. |
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.
In my opinion it doesn't make sense to disable it for specific paths only. It should be a global single boolean param.
files/file.go
Outdated
if detectDisabled { | ||
file.Type = "blob" | ||
} else { | ||
err := file.detectType(true, false) | ||
if err != nil { | ||
return err | ||
} |
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 should only disable file detection by header. Simple ext based detection shouldn't be disabled.
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.
Now I incorporate the changes from pr.
1f36922
to
f7e4b26
Compare
rules/rules.go
Outdated
@@ -9,6 +9,7 @@ import ( | |||
// Checker is a Rules checker. | |||
type Checker interface { | |||
Check(path string) bool | |||
ReadHeader() bool |
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.
I don't think that it is the right place to add this method
files/file.go
Outdated
@@ -261,7 +269,7 @@ func (i *FileInfo) readListing(checker rules.Checker) error { | |||
} else { | |||
listing.NumFiles++ | |||
|
|||
err := file.detectType(true, false) | |||
err := file.detectType(true, false, checker.ReadHeader()) |
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.
Better would be to add a boolean param to the readListing func
Instead of extending Checker interface you can add a boolean param to the FileOptions struct. |
Description
This pr solves the issue and provides a frontend to set the options.
馃毃 Before submitting your PR, please read community, and indicate which issues (in any of the repos) are either fixed or closed by this PR. See GitHub Help: Closing issues using keywords.
Further comments
If this is a relatively large or complex change, kick off the discussion by explaining why you chose the solution you did, what alternatives you considered, etc.
鉂わ笍 Thank you!