Skip to content
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

Adds ignored files as a configurable feature #3434

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

matthewbadeau
Copy link
Contributor

Checklist

🚨 Please review the guidelines for contributing to this repository. 🚨

  • Make sure you are making a pull request against our main branch (left side)
  • Check that that your branch is up to date with our main.
  • Make sure you are requesting to pull a topic/feature/bugfix branch (right side). Don't request your main!
  • Check that the tests and code linter both pass.
  • If you're a new contributor, please sign our contributor license agreement.

Warnings

  • This PR will change existing database contents.
  • This PR introduces a breaking change to existing installations.

Summary

This will add a site setting to configure ignored files. The setting is configured using regex values in the UI, separated by new lines.

Linked issues

resolves #497

Description of changes

This adds a configurable filter in the site settings UI.

Site settings UI with new file settings option

The text may need tweaking before merging as it's a little redundant. Please change as needed.

I made the section "File settings" as I think there are other things that could be added in the future, like "display preview thumbnail instead of rendering file" or something like that. I made it pretty generic.

/.*\/@eaDir\/.*/, # Synology temp files
/__MACOSX/ # MACOS resource forks
]
@@patterns ||= model_ignored_files
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this need to be a class variable anymore now that we've got :model_ignored_files?

@@ -0,0 +1,9 @@
class AddIgnoredFilesToSiteSettings < ActiveRecord::Migration[7.2]
def change
add_column :site_settings, :ignored_files, :text, null: true, default: [
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I need help figuring out the best way to do this migration.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think SiteSettings is a flexible k/v store so you don't actually need to add the migration. But I'll check when I take a proper look at this probably tomorrow.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://github.com/huacnlee/rails-settings-cached is the gem that it's using, in case those docs help.

@Floppy
Copy link
Collaborator

Floppy commented Jan 19, 2025

This looks great, thanks! Will it ignore directories too?

@matthewbadeau
Copy link
Contributor Author

As far as I know, it will ignore directories. The code is basically what you had previously but shifted around so it can be updated and stored in the DB.

I probably need to update the specs to make sure they're testing both files and directories.

@Floppy
Copy link
Collaborator

Floppy commented Jan 19, 2025

Hah, OK, I'd completely forgotten that there are some files that are ignored already. I'll have a proper look at this tomorrow when I'm not juggling children...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Exclude certain directories
2 participants