graysky2 / anything-sync-daemon

Symlinks and syncs user specified dirs to RAM thus reducing HDD/SDD calls and speeding-up the system.
https://wiki.archlinux.org/index.php/Anything-sync-daemon
MIT License
345 stars 45 forks source link

Ignore patterns #22

Closed rosshadden closed 9 years ago

rosshadden commented 9 years ago

Is there currently a way to ignore files/folders matching certain patterns?

The situation I keep hitting is that I am using asd on a project folder in which I am actively doing development. This is a perfect workflow most of the time, but the one thing a little frustrating is that it keeps syncing vim's .swp files. That is, I open a file in vim, and it creates a .swp file for it. When I close the file, the .swp files don't always get deleted, and i have to manually clean them up.

While it may not be the only solution, I think it would be useful to be able to specify a pattern to ignore (in my case *.swp). I'm not sure what "ignore" means for asd in terms of how it would be implemented, but I think the general idea makes sense.

graysky2 commented 9 years ago

The key sync step uses an rsync call so you could add an exclude statement to the code easily enough, but doing it an in conf file would just present an opportunity to jack-up the syntax, so I would have to write a routine to check it etc. Probably not something I would wanna insert at this point. You can try it by hardcoding --exclude *.swp into the rsync lines under the do_sync function as a proof of concept for your use case. What distro are you running? If it's Arch, you could even write this into your PKGBUILD with a creative sed line or two if it works.

rosshadden commented 9 years ago

Yeah I use Arch. I'll try the hardcoded exclude. Thanks!

rosshadden commented 9 years ago

I think that worked. It's hard to tell because it generally builds up over time.

Are you saying you don't want this to be configurable at all, or you don't want to have to worry about parsing/translating a custom "exclude" format into the one used by rsync? If it's the latter I completely understand... it has a stupid format for multiple unrelated excludes.

graysky2 commented 9 years ago

That's cool. If that addition works for you you can modify the PKGBUILD like this: https://gist.github.com/graysky2/f49ea711e83dc057d944

graysky2 commented 9 years ago

Yes, I don't want to add the feature to ignore because it complicates things particularly if users want multiple ignores. Try building with that PKGBUILD I provided above which should automatically make this modification for you when you build asd on Arch. That way you don't have to mess with remembering to mod the script when the version is bumped... it is highly unlikely that I will change the no-whole-file switch that is used for the sync operation so it's probably a safe bet to use to target a sed operation.

rosshadden commented 9 years ago

Okay, thanks.