Skip to content

Commit

Permalink
Add latest symlink
Browse files Browse the repository at this point in the history
  • Loading branch information
kewisch committed Apr 6, 2021
1 parent cb1e4eb commit a4946fd
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
3 changes: 3 additions & 0 deletions pyamo/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,9 @@ def find_versions(versions, page):
version.savesources(addonpath)
print(' ' + version.sourcefilename)
version.extractsources(addonpath)

version.linklatest(addonpath)

if args.run:
print('Running applicaton for %s %s' % (review.slug, versions[-1].version))
if not args.binary:
Expand Down
11 changes: 11 additions & 0 deletions pyamo/review.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from zipfile import ZipFile, BadZipfile
from urllib.parse import urlparse, urljoin, unquote
from mozprofile import FirefoxProfile
from cmp_version import cmp_version

import lxml.html
import magic
Expand Down Expand Up @@ -315,6 +316,16 @@ def extractsources(self, targetpath):
traceback.print_exc()
print("Could not extract sources due to above exception, skipping extraction")

def linklatest(self, targetpath):
dst = os.path.join(targetpath, "latest")
if os.path.islink(dst):
target = os.path.dirname(os.readlink(dst))
if cmp_version(target, self.version) > 0:
return
os.unlink(dst)

os.symlink(self.version + os.path.sep, dst)


class AddonVersionFile:
# pylint: disable=too-many-instance-attributes
Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
'lxml',
'mozrunner',
'cssselect',
'cmp_version',
'arghandler >=1.0.3',
'pylzma',
'pytz',
Expand Down

0 comments on commit a4946fd

Please sign in to comment.