1
0
mirror of https://github.com/moparisthebest/SickRage synced 2024-08-13 16:53:54 -04:00

More fixes for checkout/updating issues.

This commit is contained in:
echel0n 2014-07-30 17:19:44 -07:00
parent ad39ac8772
commit 39fe8e8477
3 changed files with 30 additions and 15 deletions

View File

@ -49,7 +49,6 @@ from sickbeard.common import SD, SKIPPED, NAMING_REPEAT
from sickbeard.databases import mainDB, cache_db, failed_db
from lib.configobj import ConfigObj
import xml.etree.ElementTree as ElementTree
PID = None
@ -102,7 +101,7 @@ VERSION_NOTIFY = False
AUTO_UPDATE = False
NOTIFY_ON_UPDATE = False
CUR_COMMIT_HASH = None
BRANCH = None
BRANCH = ''
INIT_LOCK = Lock()
started = False

View File

@ -22,12 +22,8 @@ import platform
import re
import uuid
from sickbeard import version
INSTANCE_ID = str(uuid.uuid1())
USER_AGENT = ('SickRage/' + version.SICKBEARD_VERSION.replace(' ', '-') +
' (' + platform.system() + '; ' + platform.release() +
'; ' + INSTANCE_ID + ')')
USER_AGENT = ('SickRage/(' + platform.system() + '; ' + platform.release() + '; ' + INSTANCE_ID + ')')
mediaExtensions = ['avi', 'mkv', 'mpg', 'mpeg', 'wmv',
'ogm', 'mp4', 'iso', 'img', 'divx',

View File

@ -37,6 +37,7 @@ from sickbeard import encodingKludge as ek
from subprocess import check_output, PIPE, Popen
class CheckVersion():
"""
Version check class meant to run as a thread object with the sr scheduler.
@ -115,7 +116,11 @@ class CheckVersion():
return True
def update(self):
if self.updater.need_update() or self.updater.branch != sickbeard.BRANCH:
# update branch with current config branch value
self.updater.branch == sickbeard.BRANCH
# check for updates
if self.updater.need_update():
return self.updater.update()
def list_remote_branches(self):
@ -124,6 +129,7 @@ class CheckVersion():
def get_branch(self):
return self.updater.branch
class UpdateManager():
def get_github_repo_user(self):
return 'echel0n'
@ -134,6 +140,7 @@ class UpdateManager():
def get_update_url(self):
return sickbeard.WEB_ROOT + "/home/update/?pid=" + str(sickbeard.PID)
class WindowsUpdateManager(UpdateManager):
def __init__(self):
self.github_repo_user = self.get_github_repo_user()
@ -189,11 +196,14 @@ class WindowsUpdateManager(UpdateManager):
return int(match.group(1))
def need_update(self):
if self.branch != self._find_installed_branch():
logger.log(u"Branch checkout: " + self._find_installed_branch() + "->" + self.branch, logger.DEBUG)
return True
self._cur_version = self._find_installed_version()
self._newest_version = self._find_newest_version()
logger.log(u"newest version: " + repr(self._newest_version), logger.DEBUG)
if self._newest_version and self._newest_version > self._cur_version:
return True
@ -269,7 +279,7 @@ class WindowsUpdateManager(UpdateManager):
new_update_path = os.path.join(sickbeard.PROG_DIR, u'updater.exe')
logger.log(u"Copying new update.exe file from " + old_update_path + " to " + new_update_path)
shutil.move(old_update_path, new_update_path)
# Notify update successful
notifiers.notify_git_update(sickbeard.NEWEST_VERSION_STRING)
@ -282,6 +292,7 @@ class WindowsUpdateManager(UpdateManager):
def list_remote_branches(self):
return ['windows_binaries']
class GitUpdateManager(UpdateManager):
def __init__(self):
self._git_path = self._find_working_git()
@ -500,8 +511,12 @@ class GitUpdateManager(UpdateManager):
sickbeard.NEWEST_VERSION_STRING = newest_text
def need_update(self):
self._find_installed_version()
if self.branch != self._find_installed_branch():
logger.log(u"Branch checkout: " + self._find_installed_branch() + "->" + self.branch, logger.DEBUG)
return True
self._find_installed_version()
if not self._cur_commit_hash:
return True
else:
@ -522,7 +537,7 @@ class GitUpdateManager(UpdateManager):
on the call's success.
"""
if sickbeard.BRANCH == self._find_installed_branch():
if self.branch == self._find_installed_branch():
output, err, exit_status = self._run_git(self._git_path, 'pull -f origin ' + self.branch) # @UnusedVariable
else:
output, err, exit_status = self._run_git(self._git_path, 'checkout -f ' + self.branch) # @UnusedVariable
@ -541,6 +556,7 @@ class GitUpdateManager(UpdateManager):
return re.findall('\S+\Wrefs/heads/(.*)', branches)
return []
class SourceUpdateManager(UpdateManager):
def __init__(self):
self.github_repo_user = self.get_github_repo_user()
@ -570,6 +586,10 @@ class SourceUpdateManager(UpdateManager):
def need_update(self):
if self.branch != self._find_installed_branch():
logger.log(u"Branch checkout: " + self._find_installed_branch() + "->" + self.branch, logger.DEBUG)
return True
self._find_installed_version()
try:
@ -710,8 +730,8 @@ class SourceUpdateManager(UpdateManager):
old_path = os.path.join(content_dir, dirname, curfile)
new_path = os.path.join(sickbeard.PROG_DIR, dirname, curfile)
#Avoid DLL access problem on WIN32/64
#These files needing to be updated manually
# Avoid DLL access problem on WIN32/64
# These files needing to be updated manually
#or find a way to kill the access from memory
if curfile in ('unrar.dll', 'unrar64.dll'):
try:
@ -733,7 +753,7 @@ class SourceUpdateManager(UpdateManager):
# Notify update successful
notifiers.notify_git_update(sickbeard.NEWEST_VERSION_STRING)
return True
def list_remote_branches(self):