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.
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
# -*- 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 @@
|
|||||||
# 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):
|
|||||||
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)
|
|
||||||
|
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)
|
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:
|
if os.path.exists(path):
|
||||||
permissions.append((path, int(_file.mode, 8)))
|
yield path, int(_file.mode, 8)
|
||||||
|
|
||||||
return permissions
|
|
||||||
|
|||||||
Reference in New Issue
Block a user