Skip to content

Commit

Permalink
Some refactoring to simplify future work
Browse files Browse the repository at this point in the history
  • Loading branch information
Gustavo Carvalho committed Apr 7, 2014
1 parent 9d467ba commit 0a9769e
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions RSync.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,8 @@ def main_host(self):
def excludes(self):
return self.prefs('excludes')
def local_path(self):
return self.prefs('local_path')
this_local_path = self.prefs('local_path')
return os.path.normpath(this_local_path) if this_local_path else ''
def use_ssh(self):
return self.prefs('use_ssh')
def remote_is_master(self):
Expand All @@ -155,6 +156,8 @@ def delete_slave(self):
#################################
# the work itself
def check_remote_local_git_hash(self):
if not self.valid_file_to_process():
return
if not self.prefs('check_remote_git'):
return
(ran_ok, local_hash) = run_executable([gitpath, 'rev-parse', 'HEAD'])
Expand Down Expand Up @@ -193,16 +196,23 @@ def sync_local_remote(self):
def sync_remote_local(self):
self.sync_file(False)

def sync_file(self, to_server=True):
# Need to add some checks on whether file changed before syncing
# right now, we sync way too often...
def valid_file_to_process(self):
local_file = self.view.file_name()
local_path = self.local_path()
local_path = os.path.normpath(local_path) if local_path else ''
if not local_file or not rsyncpath or not local_path:
return
return False
if not local_path.upper() in local_file.upper():
return False
return True

def sync_file(self, to_server=True):
# Need to add some checks on whether file changed before syncing
# right now, we sync way too often...
if not self.valid_file_to_process():
return
local_file = self.view.file_name()
local_path = self.local_path()

relative_path = local_file[len(os.path.normpath(local_path)) : ]
for this_host in self.hosts():
remote_path = this_host.remote_path(relative_path)
Expand Down

0 comments on commit 0a9769e

Please sign in to comment.