-
Notifications
You must be signed in to change notification settings - Fork 676
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
Add removable_storage option to rsync syncer #590
Conversation
Just added the code to rsync syncer which will check the mount point instead of the backup path |
With the checking of the mount point if the path is a sub directory of the removable_storage mount point then it won't work. EG: |
@map7 I thought the mount? check would fix the problem that |
This current solution does check if the path == your mount point, so if you mount your usb in /home/map7/usb and that is your destination path then it will work. The problem happens when you have your usb mount point as /home/map7/usb and your path set to /home/map7/usb/servers, this will not work at all. I'm trying to work around this problem. Maybe we need an extra field called remote_storage_mount_point or something? |
@map7 I woudn't want to introduce a new configuration option. Then I would need a separate class as there will be too much specific configuration. Couldn't we check if the path you are specifying is part of a mounted path? if mount_points.select { |mount_point| remote_path.include? mount_point }.length > 0
# ...
end Because the root harddisk is also a mounted point they should probably be filtered from the mount_points.reject { |x| %w(/ /dev).include? x } What do you think? |
Yes I agree, but we need to reject more than just / /dev, I've added this to the new commit. |
@map7 Ah I see, but instead wouldn't a Would that work as well? Then you don't have to add the |
Yeah you could I just like keeping my methods short On 3 October 2014 20:58:26 GMT+10:00, Tom de Bruijn notifications@github.com wrote:
|
@map7 I understand that, but now you have 2 methods, one of which ( I was thinking of maybe shortening it even more in just one method with just this: def mount_points
`mount`.scan(/^[^ ]+ on (\/dev[^ ]+)/).flatten
end What that does is finding every match of "on /dev" on every line and return every mount point in an array. This way we don't have to split, grep, map and value check the array of mount points. It will return: ["/dev", "/dev/foo", "/dev/bar"] Would you agree that this is a simpler solution? Other than this I have no other issues with this PR. Do you still want to support this in the Local storage as well? I understand I might be one of those crazies that somewhat understands regex, so I'll post a short explanation as well. /^[^ ]+ on (\/dev[^ ]+)/
|
I don't think this is simpler, but I do agree with combining both methods into one. Also I found that when I run I did play around with the regex a little and managed to get which includes my 'usb' mount in there, but I would still have to map & split. I've done regex before heaps of times but I usually leave it to a minimum because it's harder to read. Even though split, grep, map & split are longer I can see straight away what it's doing. I'll tidy it up a little in this next commit |
Yes this should be in local as well, let me add the new code to that |
mounted method for checking if the removable storage is mounted or not.
Just fixed up the storage local & rsync as well as their related tests |
@@ -20,7 +20,7 @@ def initialize(model, storage_id = nil) | |||
private | |||
|
|||
def transfer! | |||
if path_available? | |||
if mounted? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel like this rename doesn't cover what is happening. It's not just checking if the path is mounted, but it's checking if the path is available for writing and that's not what happening anymore when you read it.
@map7 I've thought about it, and unfortunately thanks to not having a lot of free time, only now came to a decision. I decided not to merge this. It adds some complexity not everyone needs and I can't really think of a good way to implement it right now in the core. I fear that it will get in the way of the normal behavior. I've added it to the backup-features issue list for now backup/backup-features#19. (It might not look active right now because it's more of a todo list for v5 of the utility. And development on v5 is done in private for now.) Thanks for the work you put in, this case will certainly stay on our minds. I hope you can use a workaround in the mean time. |
This is without the mounted? method for now, just checking for the sub directory on the removable media