mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-08 02:10:24 +00:00
[api] return the size of starred files
This commit is contained in:
@@ -263,7 +263,7 @@ class Account(ResponseMixin, View):
|
|||||||
email = request.user.username
|
email = request.user.username
|
||||||
info['email'] = email
|
info['email'] = email
|
||||||
info['usage'] = seafserv_threaded_rpc.get_user_quota_usage(email)
|
info['usage'] = seafserv_threaded_rpc.get_user_quota_usage(email)
|
||||||
info['total'] = 2 * 1024 * 1024 * 1024
|
info['total'] = seafserv_threaded_rpc.get_user_quota(email)
|
||||||
info['feedback'] = settings.DEFAULT_FROM_EMAIL
|
info['feedback'] = settings.DEFAULT_FROM_EMAIL
|
||||||
response = Response(200, [info])
|
response = Response(200, [info])
|
||||||
return self.render(response)
|
return self.render(response)
|
||||||
@@ -801,6 +801,7 @@ def append_starred_files(array, files):
|
|||||||
'path' : f.path,
|
'path' : f.path,
|
||||||
'mtime' : f.last_modified,
|
'mtime' : f.last_modified,
|
||||||
'dir' : f.is_dir,
|
'dir' : f.is_dir,
|
||||||
|
'size' : f.size
|
||||||
}
|
}
|
||||||
array.append(sfile)
|
array.append(sfile)
|
||||||
|
|
||||||
|
16
utils.py
16
utils.py
@@ -492,6 +492,18 @@ class StarredFile(object):
|
|||||||
# always 0 for dir
|
# always 0 for dir
|
||||||
self.last_modified = last_modified
|
self.last_modified = last_modified
|
||||||
|
|
||||||
|
def __init__(self, org_id, repo, path, is_dir, last_modified, size):
|
||||||
|
# always 0 for non-org repo
|
||||||
|
self.org_id = org_id
|
||||||
|
self.repo = repo
|
||||||
|
self.path = path
|
||||||
|
self.formatted_path = self.format_path()
|
||||||
|
self.is_dir = is_dir
|
||||||
|
# always 0 for dir
|
||||||
|
self.last_modified = last_modified
|
||||||
|
self.size = size;
|
||||||
|
|
||||||
|
|
||||||
# org_id > 0: get starred files in org repos
|
# org_id > 0: get starred files in org repos
|
||||||
# org_id < 0: get starred files in personal repos
|
# org_id < 0: get starred files in personal repos
|
||||||
def get_starred_files(email, org_id=-1):
|
def get_starred_files(email, org_id=-1):
|
||||||
@@ -515,9 +527,11 @@ def get_starred_files(email, org_id=-1):
|
|||||||
|
|
||||||
# file still exists?
|
# file still exists?
|
||||||
file_id = ''
|
file_id = ''
|
||||||
|
size = -1;
|
||||||
if sfile.path != "/":
|
if sfile.path != "/":
|
||||||
try:
|
try:
|
||||||
file_id = seafserv_threaded_rpc.get_file_by_path(sfile.repo_id, sfile.path)
|
file_id = seafserv_threaded_rpc.get_file_by_path(sfile.repo_id, sfile.path)
|
||||||
|
size = seafserv_threaded_rpc.get_file_size(file_id)
|
||||||
except SearpcError:
|
except SearpcError:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
@@ -531,7 +545,7 @@ def get_starred_files(email, org_id=-1):
|
|||||||
path_hash = md5_constructor(urllib2.quote(sfile.path.encode('utf-8'))).hexdigest()[:12]
|
path_hash = md5_constructor(urllib2.quote(sfile.path.encode('utf-8'))).hexdigest()[:12]
|
||||||
last_modified = get_file_contributors(sfile.repo_id, sfile.path, path_hash, file_id)[1]
|
last_modified = get_file_contributors(sfile.repo_id, sfile.path, path_hash, file_id)[1]
|
||||||
|
|
||||||
f = StarredFile(sfile.org_id, repo, sfile.path, sfile.is_dir, last_modified)
|
f = StarredFile(sfile.org_id, repo, sfile.path, sfile.is_dir, last_modified, size)
|
||||||
|
|
||||||
ret.append(f)
|
ret.append(f)
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user