def get_dir_files_last_modified(repo_id, parent_dir, dir_id=None): '''Calc the last modified time of all the files under the directory <parent_dir> of the repo <repo_id>. Return a dict whose keys are the file names and values are their corresponding last modified timestamps. ''' if not dir_id: dir_id = seafserv_threaded_rpc.get_dir_id_by_path(repo_id, parent_dir) parent_dir_hash = calc_file_path_hash(parent_dir) if not dir_id: return {} try: info = DirFilesLastModifiedInfo.objects.get(repo_id=repo_id, parent_dir_hash=parent_dir_hash) except DirFilesLastModifiedInfo.DoesNotExist: # no cache yet return calc_dir_files_last_modified(repo_id, parent_dir, parent_dir_hash, dir_id) else: # cache exist if info.dir_id != dir_id: # cache is outdated info.delete() return calc_dir_files_last_modified(repo_id, parent_dir, parent_dir_hash, dir_id) else: # cache is valid return json.loads(info.last_modified_info)
def group_wiki_pages(request, group): """ List wiki pages in group. """ repo = find_wiki_repo(request, group) if not repo: return render_error(request, _('Wiki is not found.')) try: dir_id = seafserv_threaded_rpc.get_dir_id_by_path(repo.id, '/') except SearpcError, e: dir_id = None
def get(self, request, repo_id, format=None): # list dir repo = get_repo(repo_id) if not repo: return api_error(status.HTTP_404_NOT_FOUND, 'Repo not found.') resp = check_repo_access_permission(request, repo) if resp: return resp path = request.GET.get('p', '/') if path[-1] != '/': path = path + '/' try: dir_id = seafserv_threaded_rpc.get_dir_id_by_path( repo_id, path.encode('utf-8')) except SearpcError, e: return api_error(HTTP_520_OPERATION_FAILED, "Failed to get dir id by path.")
def get(self, request, repo_id, format=None): # list dir repo = get_repo(repo_id) if not repo: return api_error(status.HTTP_404_NOT_FOUND, 'Repo not found.') resp = check_repo_access_permission(request, repo) if resp: return resp path = request.GET.get('p', '/') if path[-1] != '/': path = path + '/' try: dir_id = seafserv_threaded_rpc.get_dir_id_by_path(repo_id, path.encode('utf-8')) except SearpcError, e: return api_error(HTTP_520_OPERATION_FAILED, "Failed to get dir id by path.")