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

is ** pattern supported ? #20

Open
haoadoreorange opened this issue Jun 1, 2021 · 10 comments
Open

is ** pattern supported ? #20

haoadoreorange opened this issue Jun 1, 2021 · 10 comments
Labels
bug Something isn't working

Comments

@haoadoreorange
Copy link
Contributor

is ** pattern supported (any location) ?

@haoadoreorange haoadoreorange added the enhancement New feature or request label Jun 1, 2021
@sp1thas
Copy link
Owner

sp1thas commented Jun 5, 2021

Hello @haoadoresorange

Yep, I just checked this and it seems to work fine:

~ mkdir tmp-folder
➜  ~ touch tmp-folder/tmp.txt
➜  ~ mkdir tmp-folder/tmp-folder2
➜  ~ tree tmp-folder
tmp-folder
├── tmp-folder2
└── tmp.txt

1 directory, 1 file
➜  ~ echo '**' > tmp-folder/.dropboxignore
➜  ~ cd tmp-folder
➜  tmp-folder tree .
.
├── tmp-folder2
└── tmp.txt

1 directory, 1 file
➜  tmp-folder dropboxignore ignore .

Total number of ignored files: 2
Total number of ignored folders: 2

There is probably and issue on file counting but the files are ignored from dropbox.

@sp1thas sp1thas added question Further information is requested and removed enhancement New feature or request labels Jun 5, 2021
@haoadoreorange
Copy link
Contributor Author

image
image
Even a 1-level-sub-folder is not working, do you any idea what is the problem ? I might look into that
image

@haoadoreorange
Copy link
Contributor Author

any news @sp1thas ?

@sp1thas
Copy link
Owner

sp1thas commented Jun 21, 2021

Hello @haoadoresorange ,

you are right, based on current implementation, double asterisks are not supported. On the other hand, a recursive match is enabled by mistakes, therefore, abc is equal to **/abc and this is totally wrong. .gitignore files don't work in this way and .dropboxignore files should not work in this way too. dropboxignore uses find to match files, therefore, -max-depth should be used to prevent recursive matches.

I will start working on this asap in order to fix the wrong recursive matching and to support patterns like **/abc, abc/**, etc.

Thanks for your feedback.

@sp1thas sp1thas added bug Something isn't working and removed question Further information is requested labels Jun 21, 2021
@haoadoreorange
Copy link
Contributor Author

haoadoreorange commented Jun 21, 2021

So I looked into it a bit and see that we have a very simple solution here:

  • instead of using dirname and basename, we use regex to capture it instead in order to conserve the glob pattern (or maybe there is an option for that).
  • now if the dirname part contains any glob pattern AND not for the file in current dir (because find ./*.extension doesn't work), we directly use find for the whole path as find /path/with/glob with globstar option enabled.
  • otherwise we find as normal with -maxdepth 1.

Tell me if it covers everything, I will make a PR.

@sp1thas
Copy link
Owner

sp1thas commented Jun 25, 2021

@haoadoresorange I totally agree about the second and the third bullet of you comment. It's not really clear to me how we gonna use -regex. Could you provide an example with find -regex ... that could be used in our case?

note 1: we must keep the format of .dropboxignore as similar as posible to .gitignore format.
note 2: I came across this bash implementation and it seems quite promising (not tested yet).

@haoadoreorange
Copy link
Contributor Author

haoadoreorange commented Jun 26, 2021

I just tested it, it isn't working (I think), because of one line that seems pretty weird

xargs -n1 find . -type d -name .git -prune -o -type f -path

overall however, I think the script does what you did in your script already.
the regex can be something simple like this (.*)\/(.+)
EDIT: what I mean by using regex is not to use regex with find, but to break the path down using regex and then look into the path to decide what to do with it.
EDIT2: once we know what to do with just find using the path

@smalltimer
Copy link

smalltimer commented Jan 19, 2022

Hi, this is a really nice utility to have and thank you very much for sharing it !

I can confirm that ** patterns are not picked up, but the search is recursive by default. In addition, I also get an auto-ignore for:

  1. The folder .../Dropbox/.dropbox.cache/
  2. Vault.dbx-vault

Is this intentional? I don't know what these files and folders do and I am wondering if it is safe to auto-ignore them. If so, it would be nice to have that in the documentation so totally clueless folk like me are not caught unawares!

@sp1thas
Copy link
Owner

sp1thas commented Feb 17, 2022

Thanks @haoadoresorange for your effort, unfortunately I didn't had the time to investigate the case of ** further. I will do my best to explore ways to support **. My first thought was to find a way to support ** in order to support .gitignore file patterns directly but this seems to be tricky.

@smalltimer thank you so much for your feedback. dropboxignore should not auto-ignore anything, therefore I would like to ask you to provide a reproducible example of your case. Please provide some the basic folder structure, the current directory, the content of the .dropboxignore (if exists), the actual command (using --debug) and the standard output. Given that the this issue is not related to ** I'm encourage you to open a new issue.

@haoadoreorange
Copy link
Contributor Author

Thanks @haoadoresorange for your effort, unfortunately I didn't had the time to investigate the case of ** further. I will do my best to explore ways to support **. My first thought was to find a way to support ** in order to support .gitignore file patterns directly but this seems to be tricky.

Hi actually stopped using dropboxignore a while ago ): I switched to insync which allow an ignore file for dropbox and other services.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
v2.0 Refactoring
  
Awaiting triage
Development

No branches or pull requests

3 participants