havardgulldahl / jottalib

A library to access files stored at jottacloud.com.
GNU General Public License v3.0
83 stars 19 forks source link

Add support for exclude patterns #44

Closed mortenlj closed 9 years ago

mortenlj commented 9 years ago

I have Synology NAS, which adds extra directories with thumbnails all over the place. I'd like to use jottacloudclientscanner to backup my photos, but I need to exclude all the thumbnail-folders.

The simple solution is to add support for a regex matched against the entire source path, and skip the file if it matches the pattern.

mortenlj commented 9 years ago

I'll see if I can manage to code something up in the next week or two.

havardgulldahl commented 9 years ago

Cheers, @mortenlj !

This seems legit, both the use case and the implementation. Will you please provide an example on how to use it?

Also, we sorely need to get py.test running on jottacloudclientscanner.py. any ideas on how best to do that?

mortenlj commented 9 years ago

Example usage:

I have these files on my local machine:

╼ find ~/Documents/Tech/
/home/fimojoha/Documents/Tech/
/home/fimojoha/Documents/Tech/rc082-010d-cloud-computing.pdf
/home/fimojoha/Documents/Tech/rc123-010d-html5_1.pdf
/home/fimojoha/Documents/Tech/rc094-010d-git_1.pdf
/home/fimojoha/Documents/Tech/stylish_exclude_rules.txt
/home/fimojoha/Documents/Tech/git_cheat.rst
/home/fimojoha/Documents/Tech/rc120-010d-solr_0.pdf
/home/fimojoha/Documents/Tech/rc043-010d-scalability_3.pdf
/home/fimojoha/Documents/Tech/Solr technical introduction.pdf
/home/fimojoha/Documents/Tech/rc153-010d-Cassandra.pdf

I want to back them up, except the git related documents, because I don't really like git:

╼ jottacloudclientscanner.py --dry-run --exclude git ~/Documents/Tech/ /mymachine/archive/tech
Entering dir: /home/fimojoha/Documents/Tech/
uploading 7 new files: [●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●] 7/7 - 00:00:00
Network upload speed 0B/sec
Finished syncing 0 files to JottaCloud, no errors. yay!

Here the pattern is just the simple "git", but it could be an advanced regular expression.

As for py.test, I'm afraid I don't have any good ideas.

havardgulldahl commented 9 years ago

@mortenlj I have taken another look, and I added some comments to your code. If you want to talk about it, maybe you will join us at https://gitter.im/havardgulldahl/jottalib ?

It's a good place to discuss implementation details and expectations.