dropboxignore icon indicating copy to clipboard operation
dropboxignore copied to clipboard

is ** pattern supported ?

Open haoadoreorange opened this issue 3 years ago • 10 comments

is ** pattern supported (any location) ?

haoadoreorange avatar Jun 01 '21 23:06 haoadoreorange

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 avatar Jun 05 '21 11:06 sp1thas

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 avatar Jun 07 '21 14:06 haoadoreorange

any news @sp1thas ?

haoadoreorange avatar Jun 20 '21 18:06 haoadoreorange

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 avatar Jun 21 '21 07:06 sp1thas

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.

haoadoreorange avatar Jun 21 '21 22:06 haoadoreorange

@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).

sp1thas avatar Jun 25 '21 16:06 sp1thas

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

haoadoreorange avatar Jun 26 '21 17:06 haoadoreorange

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!

smalltimer avatar Jan 19 '22 18:01 smalltimer

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.

sp1thas avatar Feb 17 '22 08:02 sp1thas

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.

haoadoreorange avatar Feb 17 '22 13:02 haoadoreorange