Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Merge branch 'master' of github.com:midgetspy/Sick-Beard into windows…

…_binaries
  • Loading branch information...
commit a12bf64beadd31c919d392aa629e58ca36c2bdbe 2 parents de6a39f + 94c899a
Nic Wolfe midgetspy authored

Showing 1 changed file with 23 additions and 6 deletions. Show diff stats Hide diff stats

  1. +23 6 sickbeard/versionChecker.py
29 sickbeard/versionChecker.py
@@ -20,7 +20,7 @@
20 20 from sickbeard import helpers, version
21 21 from sickbeard import logger
22 22
23   -import os, os.path, platform
  23 +import os, os.path, platform, shutil, time
24 24 import subprocess, re
25 25 import urllib, urllib2
26 26 import zipfile, tarfile
@@ -139,21 +139,38 @@ def update(self):
139 139 logger.log(u"Downloading update file from "+str(new_link))
140 140 (filename, headers) = urllib.urlretrieve(new_link)
141 141
142   - # unzip it to sb-update
  142 + # prepare the update dir
143 143 sb_update_dir = os.path.join(sickbeard.PROG_DIR, 'sb-update')
  144 + logger.log(u"Clearing out update folder "+sb_update_dir+" before unzipping")
  145 + if os.path.isdir(sb_update_dir):
  146 + shutil.rmtree(sb_update_dir)
  147 +
  148 + # unzip it to sb-update
144 149 logger.log(u"Unzipping from "+str(filename)+" to "+sb_update_dir)
145 150 update_zip = zipfile.ZipFile(filename, 'r')
146 151 update_zip.extractall(sb_update_dir)
147 152 update_zip.close()
  153 +
  154 + # find update dir name
  155 + update_dir_contents = os.listdir(sb_update_dir)
  156 + if len(update_dir_contents) != 1:
  157 + logger.log("Invalid update data, update failed.", logger.ERROR)
  158 + return False
  159 +
  160 + content_dir = os.path.join(sb_update_dir, update_dir_contents[0])
  161 + old_update_path = os.path.join(content_dir, 'updater.exe')
  162 + new_update_path = os.path.join(sickbeard.PROG_DIR, 'updater.exe')
  163 + logger.log(u"Copying new update.exe file from "+old_update_path+" to "+new_update_path)
  164 + shutil.move(old_update_path, new_update_path)
  165 +
  166 + # delete the zip
  167 + logger.log(u"Deleting zip file from "+str(filename))
  168 + os.remove(filename)
148 169
149 170 except Exception, e:
150 171 logger.log(u"Error while trying to update: "+str(e).decode('utf-8'), logger.ERROR)
151 172 return False
152 173
153   - # delete the zip
154   - logger.log(u"Deleting old update file from "+str(filename))
155   - os.remove(filename)
156   -
157 174 return True
158 175
159 176 class GitUpdateManager(UpdateManager):

0 comments on commit a12bf64

Please sign in to comment.
Something went wrong with that request. Please try again.