diff --git a/src/core/wopiutils.py b/src/core/wopiutils.py index 6cb61964..a9784dfb 100644 --- a/src/core/wopiutils.py +++ b/src/core/wopiutils.py @@ -167,6 +167,8 @@ def retrieveWopiLock(fileid, operation, lock, acctok, overridefilename=None): encacctok = flask.request.args['access_token'][-20:] if 'access_token' in flask.request.args else 'N/A' lockcontent = st.getlock(acctok['endpoint'], overridefilename if overridefilename else acctok['filename'], acctok['userid']) if not lockcontent: + log.warning('msg="%s" user="%s" filename="%s" token="%s" error="WOPI lock not found, ignoring"' % + (operation.title(), acctok['userid'][-20:], acctok['filename'], encacctok)) return None # no pre-existing lock found, or error attempting to read it: assume it does not exist try: # check validity: a lock is deemed expired if the most recent between its expiration time and the last @@ -308,10 +310,10 @@ def storeWopiLock(fileid, operation, lock, oldlock, acctok, isoffice): # another session was faster than us, or the file was already WOPI-locked: # get the lock that was set retrievedLock = retrieveWopiLock(fileid, operation, lock, acctok) - if not compareWopiLocks(retrievedLock, (oldlock if oldlock else lock)): + if retrievedLock and not compareWopiLocks(retrievedLock, (oldlock if oldlock else lock)): return makeConflictResponse(operation, retrievedLock, lock, oldlock, acctok['filename'], \ 'The file was locked by another online editor') - # else it's our lock, refresh it and return + # else it's our lock or it had expired, refresh it and return st.refreshlock(acctok['endpoint'], acctok['filename'], acctok['userid'], _makeLock(lock)) log.info('msg="%s" filename="%s" token="%s" lock="%s" result="refreshed"' % (operation.title(), acctok['filename'], flask.request.args['access_token'][-20:], lock)) diff --git a/src/core/xrootiface.py b/src/core/xrootiface.py index da45ae3f..615230d9 100644 --- a/src/core/xrootiface.py +++ b/src/core/xrootiface.py @@ -90,9 +90,12 @@ def _xrootcmd(endpoint, cmd, subcmd, userid, args): if rc != '0': # failure: get info from stderr, log and raise msg = res[1][res[1].find('=')+1:].strip('\n') - if ENOENT_MSG.lower() in msg or 'unable to get attribute' in msg or EXCL_XATTR_MSG in msg: + if ENOENT_MSG.lower() in msg or 'unable to get attribute' in msg: log.info('msg="Invoked xroot on non-existing entity" cmd="%s" subcmd="%s" args="%s" error="%s" rc="%s"' % \ (cmd, subcmd, args, msg, rc.strip('\00'))) + elif EXCL_XATTR_MSG in msg: + log.info('msg="Invoked setxattr on an already locked entity" cmd="%s" subcmd="%s" args="%s" error="%s" rc="%s"' % \ + (cmd, subcmd, args, msg, rc.strip('\00'))) else: log.error('msg="Error with xroot" cmd="%s" subcmd="%s" args="%s" error="%s" rc="%s"' % \ (cmd, subcmd, args, msg, rc.strip('\00')))