cc-3936:
Added reset owners function for safe use. Changed the return mechanics of add_file_owner.
This commit is contained in:
parent
899d76ecbb
commit
8e6bc0bede
|
@ -4,17 +4,27 @@ log = get_logger()
|
|||
# hash: 'filepath' => owner_id
|
||||
owners = {}
|
||||
|
||||
def reset_owners():
|
||||
"""
|
||||
Wipes out all file => owner associations
|
||||
"""
|
||||
global owners
|
||||
owners = {}
|
||||
|
||||
def add_file_owner(f,owner):
|
||||
"""
|
||||
Associate file f with owner. If owner is -1 then do we will not record it
|
||||
because -1 means there is no owner
|
||||
because -1 means there is no owner. Returns True if f is being stored after
|
||||
the function. False otherwise.
|
||||
"""
|
||||
if owner == -1: return None
|
||||
if owner == -1: return False
|
||||
if f in owners:
|
||||
if owner != owners[f]: # check for fishiness
|
||||
log.info("Warning ownership of file '%s' changed from '%d' to '%d'"
|
||||
% (f, owners[f], owner))
|
||||
else: return True
|
||||
owners[f] = owner
|
||||
return True
|
||||
|
||||
def has_owner(f):
|
||||
"""
|
||||
|
|
Loading…
Reference in New Issue