Kaydet (Commit) 837839ab authored tarafından Fatih Aşıcı's avatar Fatih Aşıcı

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.
üst 7a1c3919
# -*- coding: utf-8 -*- # -*- 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 # 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 # the terms of the GNU General Public License as published by the Free
...@@ -10,7 +10,6 @@ ...@@ -10,7 +10,6 @@
# Please read the COPYING file. # Please read the COPYING file.
import os import os
import stat
import gettext import gettext
__trans = gettext.translation("pisi", fallback=True) __trans = gettext.translation("pisi", fallback=True)
...@@ -150,15 +149,13 @@ def find_permission_changes(oldfiles, newfiles): ...@@ -150,15 +149,13 @@ def find_permission_changes(oldfiles, newfiles):
for f in newfiles.list: for f in newfiles.list:
files_new.setdefault(f.hash, []).append(f) files_new.setdefault(f.hash, []).append(f)
hashes_new = set(map(lambda f:f.hash, newfiles.list)) for old_file in oldfiles.list:
hashes_old = set(map(lambda f:f.hash, oldfiles.list)) files = files_new.get(old_file.hash, [])
unchanged = hashes_new.intersection(hashes_old)
permissions = [] for _file in files:
for h in unchanged: if old_file.mode == _file.mode:
for _file in files_new[h]: continue
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 path = os.path.join(ctx.config.dest_dir(), _file.path)
if os.path.exists(path):
yield path, int(_file.mode, 8)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment