Skip to content

Commit

Permalink
sort egg files by modified time in egg storage
Browse files Browse the repository at this point in the history
  • Loading branch information
Umair Ashraf committed May 8, 2014
1 parent 439f0c1 commit a5ab226
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions scrapyd/eggstorage.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from os import path, makedirs, remove
from shutil import copyfileobj, rmtree
from distutils.version import LooseVersion
from operator import itemgetter

from zope.interface import implements

Expand Down Expand Up @@ -31,10 +32,13 @@ def get(self, project, version=None):
return version, open(self._eggpath(project, version), 'rb')

def list(self, project):
eggdir = path.join(self.basedir, project)
versions = [path.splitext(path.basename(x))[0] \
for x in glob("%s/*.egg" % eggdir)]
return sorted(versions, key=LooseVersion)
eggts, eggdir = [], path.join(self.basedir, project)
for eggfile in glob("%s/*.egg" % eggdir):
eggts.append((path.getmtime(eggfile), eggfile))
eggts.sort(key=itemgetter(0))
versions = [path.splitext(path.basename(x[1]))[0] \
for x in eggts]
return versions

def delete(self, project, version=None):
if version is None:
Expand Down

0 comments on commit a5ab226

Please sign in to comment.