From e80328d6e42b745a6e8c6921dc5b6b1c81770410 Mon Sep 17 00:00:00 2001 From: abbeyokgo Date: Fri, 16 Nov 2018 13:29:47 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E4=B8=8A=E4=BC=A0=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- function.py | 14 ++++++++++---- upload/README.md | 0 2 files changed, 10 insertions(+), 4 deletions(-) mode change 100755 => 100644 upload/README.md diff --git a/function.py b/function.py index fe1f1e5..0b6f121 100755 --- a/function.py +++ b/function.py @@ -42,7 +42,7 @@ def convert2unicode(string): def get_value(key,user='A'): allow_key=['client_secret','client_id'] - print('get user {}\'s {}'.format(user,key)) + #print('get user {}\'s {}'.format(user,key)) if key not in allow_key: return u'禁止获取' config_path=os.path.join(config_dir,'config.py') @@ -575,15 +575,16 @@ def _GetAllFile(parent_id="",parent_path="",filelist=[]): def AddResource(data,user='A'): #检查父文件夹是否在数据库,如果不在则获取添加 grand_path=data.get('parentReference').get('path').replace('/drive/root:','') + share_path=od_users.get(user).get('share_path') if grand_path=='': parent_id='' grandid=0 else: - g=GetItemThread(Queue()) + g=GetItemThread(Queue(),user) parent_id=data.get('parentReference').get('id') grandid=len(data.get('parentReference').get('path').replace('/drive/root:','').split('/'))-1 grand_path=grand_path[1:] - parent_path='' + parent_path='/' pid='' for idx,p in enumerate(grand_path.split('/')): parent=items.find_one({'name':p,'grandid':idx,'parent':pid}) @@ -593,8 +594,12 @@ def AddResource(data,user='A'): else: parent_path='/'.join([parent_path,p]) fdata=g.GetItemByPath(parent_path) + path=user+':/'+parent_path.replace('///','/') + path=path.replace('///','/').replace('//','/') item={} item['type']='folder' + item['user']=user + item['order']=0 item['name']=fdata.get('name') item['id']=fdata.get('id') item['size']=humanize.naturalsize(fdata.get('size'), gnu=True) @@ -602,6 +607,7 @@ def AddResource(data,user='A'): item['lastModtime']=date_to_char(parse(fdata['lastModifiedDateTime'])) item['grandid']=idx item['parent']=pid + item['path']=path items.insert_one(item) pid=fdata.get('id') #插入数据 @@ -623,7 +629,7 @@ def AddResource(data,user='A'): path=path[1:] if path=='': path=convert2unicode(data['name']) - item['path']=path + item['path']=user+':/'+path if GetExt(data['name']) in ['bmp','jpg','jpeg','png','gif']: item['order']=3 key1='name:{}'.format(data['id']) diff --git a/upload/README.md b/upload/README.md old mode 100755 new mode 100644