def test_can_unlock_file(self): if not LOCAL_PRO_DEV_ENV: return self.login_as(self.user) # lock file for test seafile_api.lock_file(self.repo_id, self.file_path.lstrip('/'), self.user.username, -1) # check file has been locked when init return_value = seafile_api.check_file_lock(self.repo_id, self.file_path.lstrip('/'), self.user.username) assert return_value == 2 # unlock file data = 'operation=unlock' resp = self.client.put(self.url + '?p=' + self.file_path, data, 'application/x-www-form-urlencoded') self.assertEqual(200, resp.status_code) # check file has been unlocked return_value = seafile_api.check_file_lock(self.repo_id, self.file_path.lstrip('/'), self.user.username) assert return_value == 0
def check_file_lock(repo_id, file_path, username): """ check if file is locked to current user according to returned value of seafile_api.check_file_lock: 0: not locked 1: locked by other 2: locked by me -1: error return (is_locked, locked_by_me) """ try: return_value = seafile_api.check_file_lock(repo_id, file_path.lstrip('/'), username) except SearpcError as e: logger.error(e) return (None, None) if return_value == 0: return (False, False) elif return_value == 1: return (True, False) elif return_value == 2: return (True, True) else: return (None, None)
def check_file_lock(repo_id, file_path, username): """ check if file is locked to current user according to returned value of seafile_api.check_file_lock: 0: not locked 1: locked by other 2: locked by me -1: error return (is_locked, locked_by_me) """ try: return_value = seafile_api.check_file_lock(repo_id, file_path.lstrip('/'), username) except SearpcError as e: logger.error(e) return (None, None) if return_value == 0: return (False, False) elif return_value == 1: return (True , False) elif return_value == 2: return (True, True) else: return (None, None)
def check_file_lock(repo_id, file_path, username): """ Check if file is locked to current user According to returned value of seafile_api.check_file_lock: 0: not locked 1: locked by other 2: locked by me -1: error Return (is_locked, locked_by_me) """ if not is_pro_version() or not ENABLE_FOLDER_PERM: return (False, False) return_value = seafile_api.check_file_lock(repo_id, file_path.lstrip('/'), username) if return_value == 0: return (False, False) elif return_value == 1: return (True , False) elif return_value == 2: return (True, True) else: raise SearpcError('check file lock error')
def check_file_lock(repo_id, file_path, username): """ Check if file is locked to current user According to returned value of seafile_api.check_file_lock: 0: not locked 1: locked by other 2: locked by me -1: error Return (is_locked, locked_by_me) """ if not is_pro_version(): return (False, False) return_value = seafile_api.check_file_lock(repo_id, file_path.lstrip('/'), username) if return_value == 0: return (False, False) elif return_value == 1: return (True , False) elif return_value == 2: return (True, True) else: raise SearpcError('check file lock error')