From 837839abc83d566565f169e19cffccba35fe90dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fatih=20A=C5=9F=C4=B1c=C4=B1?= Date: Fri, 7 May 2010 22:06:12 +0000 Subject: [PATCH] delta: Use installdb data to find permission changes stat calls are expensive. We already have the old permission info in InstallDB. This fixes the performance regression caused by 26893. --- pisi/operations/delta.py | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/pisi/operations/delta.py b/pisi/operations/delta.py index 01cba96c..bb71bd6f 100644 --- a/pisi/operations/delta.py +++ b/pisi/operations/delta.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- # -# Copyright (C) 2007, TUBITAK/UEKAE +# Copyright (C) 2007-2010, TUBITAK/UEKAE # # This program is free software; you can redistribute it and/or modify it under # the terms of the GNU General Public License as published by the Free @@ -10,7 +10,6 @@ # Please read the COPYING file. import os -import stat import gettext __trans = gettext.translation("pisi", fallback=True) @@ -150,15 +149,13 @@ def find_permission_changes(oldfiles, newfiles): for f in newfiles.list: files_new.setdefault(f.hash, []).append(f) - hashes_new = set(map(lambda f:f.hash, newfiles.list)) - hashes_old = set(map(lambda f:f.hash, oldfiles.list)) - unchanged = hashes_new.intersection(hashes_old) + for old_file in oldfiles.list: + files = files_new.get(old_file.hash, []) + + for _file in files: + if old_file.mode == _file.mode: + continue - permissions = [] - for h in unchanged: - for _file in files_new[h]: path = os.path.join(ctx.config.dest_dir(), _file.path) - if os.path.exists(path) and oct(stat.S_IMODE(os.stat(path)[stat.ST_MODE])) != _file.mode: - permissions.append((path, int(_file.mode, 8))) - - return permissions + if os.path.exists(path): + yield path, int(_file.mode, 8)