mirror of
https://github.com/f-droid/fdroidserver.git
synced 2025-10-08 18:31:07 +03:00
reuse os.stat() result when checking for non-APK files
This should make things a bit more efficient when running on lots of files, unless python was already caching the result...
This commit is contained in:
parent
07ce948809
commit
8e45d30020
1 changed files with 6 additions and 5 deletions
|
@ -517,15 +517,16 @@ def scan_repo_files(apkcache, repodir, knownapks, use_date_from_file=False):
|
||||||
cachechanged = False
|
cachechanged = False
|
||||||
repo_files = []
|
repo_files = []
|
||||||
for name in os.listdir(repodir):
|
for name in os.listdir(repodir):
|
||||||
filename = os.path.join(repodir, name)
|
|
||||||
file_extension = common.get_file_extension(name)
|
|
||||||
if name in ['index.jar', 'index.xml', 'index.html', 'categories.txt', ]:
|
if name in ['index.jar', 'index.xml', 'index.html', 'categories.txt', ]:
|
||||||
continue
|
continue
|
||||||
|
file_extension = common.get_file_extension(name)
|
||||||
if file_extension == 'apk' or file_extension == 'obb':
|
if file_extension == 'apk' or file_extension == 'obb':
|
||||||
continue
|
continue
|
||||||
|
filename = os.path.join(repodir, name)
|
||||||
if not os.path.isfile(filename):
|
if not os.path.isfile(filename):
|
||||||
continue
|
continue
|
||||||
if os.stat(filename).st_size == 0:
|
stat = os.stat(filename)
|
||||||
|
if stat.st_size == 0:
|
||||||
logging.error(filename + ' is zero size!')
|
logging.error(filename + ' is zero size!')
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
|
@ -552,13 +553,13 @@ def scan_repo_files(apkcache, repodir, knownapks, use_date_from_file=False):
|
||||||
srcfilename = name + ".src.tar.gz"
|
srcfilename = name + ".src.tar.gz"
|
||||||
if os.path.exists(os.path.join(repodir, srcfilename)):
|
if os.path.exists(os.path.join(repodir, srcfilename)):
|
||||||
repo_file['srcname'] = srcfilename
|
repo_file['srcname'] = srcfilename
|
||||||
repo_file['size'] = os.path.getsize(filename)
|
repo_file['size'] = stat.st_size
|
||||||
|
|
||||||
apkcache[name] = repo_file
|
apkcache[name] = repo_file
|
||||||
cachechanged = True
|
cachechanged = True
|
||||||
|
|
||||||
if use_date_from_file:
|
if use_date_from_file:
|
||||||
timestamp = os.stat(filename).st_ctime
|
timestamp = stat.st_ctime
|
||||||
default_date_param = datetime.fromtimestamp(timestamp).utctimetuple()
|
default_date_param = datetime.fromtimestamp(timestamp).utctimetuple()
|
||||||
else:
|
else:
|
||||||
default_date_param = None
|
default_date_param = None
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue