Skip to content

Commit

Permalink
Release 0.14.2
Browse files Browse the repository at this point in the history
  • Loading branch information
ngld committed Jun 27, 2020
2 parents 5d2dbaf + c3d56bc commit 99450f8
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 13 deletions.
2 changes: 1 addition & 1 deletion knossos/center.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

# The version should follow the http://semver.org guidelines.
# Only remove the -dev tag if you're making a release!
VERSION = '0.14.1'
VERSION = '0.14.2'
UPDATE_LINK = 'https://fsnebula.org/knossos'
INNOEXTRACT_LINK = 'https://fsnebula.org/storage/knossos/innoextract.json'
DEBUG = os.getenv('KN_DEBUG', '0').strip() == '1'
Expand Down
42 changes: 31 additions & 11 deletions knossos/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,17 +74,36 @@ def work1(self, part):
self._private = data
elif part == '#public':
raw_data = None
dest_path = os.path.join(center.settings_path, 'mods.json')
headers = {}

for link in center.REPOS:
raw_data = util.get(link, raw=True)
if raw_data:
break
if os.path.isfile(dest_path + '.etag'):
with open(dest_path + '.etag', 'r') as hdl:
headers['If-None-Match'] = hdl.read()

if not raw_data:
return
with open(dest_path + '.tmp', 'wb') as dest:
for link in center.REPOS:
result = util.download(link, dest, headers, get_etag=True)
if result == 304 or result:
data.base = link

if result not in (304, True):
# We got an ETag
with open(dest_path + '.etag', 'w') as hdl:
hdl.write(result)

break

info = os.stat(dest_path + '.tmp')
if info.st_size > 0:
os.unlink(dest_path)
os.rename(dest_path + '.tmp', dest_path)
else:
os.unlink(dest_path + '.tmp')

with open(dest_path, 'r') as dest:
data.parse(dest.read())

data.base = raw_data.url
data.parse(raw_data.text)
self._public = data

except Exception:
Expand All @@ -98,13 +117,14 @@ def work2(self, _):
if not self._public:
return

data = Repo()
data.merge(self._public)
if self._public:
data = self._public
else:
data = Repo()

if self._private:
data.merge(self._private)

data.save_json(os.path.join(center.settings_path, 'mods.json'))
center.mods = data

def finish(self):
Expand Down
5 changes: 4 additions & 1 deletion knossos/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ def _get_download_chunk_size():
return min(int(center.settings['download_bandwidth'] / 2), DEFAULT_CHUNK_SIZE)


def download(link, dest, headers=None, random_ua=False, timeout=60, continue_=False):
def download(link, dest, headers=None, random_ua=False, timeout=60, continue_=False, get_etag=False):
global HTTP_SESSION, DL_POOL, _DL_CANCEL

if headers is None:
Expand Down Expand Up @@ -467,6 +467,9 @@ def download(link, dest, headers=None, random_ua=False, timeout=60, continue_=Fa
except Exception:
pass

if get_etag:
return result.headers.get('etag', True)

return True


Expand Down
4 changes: 4 additions & 0 deletions knossos/windows.py
Original file line number Diff line number Diff line change
Expand Up @@ -507,6 +507,9 @@ def search_mods(self, search_filter=None, ignore_retail_dependency=False):
mv['installed'] = False
mv['dev_mode'] = False

if self._mod_filter != 'develop':
del mv['packages']

item['versions'].append(mv)

if item['installed'] and not item['versions'][0]['installed']:
Expand Down Expand Up @@ -555,6 +558,7 @@ def update_mod_list(self):
if filter_ in ('home', 'explore', 'develop'):
updated_mods = self._compute_mod_list_diff(result)
mod_order = [item['id'] for item in result]

self.browser_ctrl.bridge.updateModlist.emit(json.dumps(updated_mods), filter_, mod_order)

def show_indicator(self):
Expand Down

0 comments on commit 99450f8

Please sign in to comment.