checkifupdate
This commit is contained in:
parent
eeedf01598
commit
6ec84175d4
@ -19,29 +19,30 @@ class FileStorage:
|
|||||||
p = os.path.join(self.root,path)
|
p = os.path.join(self.root,path)
|
||||||
return p
|
return p
|
||||||
|
|
||||||
def _name2path(name):
|
def _name2path(self,name):
|
||||||
name = os.path.basename(name)
|
name = os.path.basename(name)
|
||||||
paths=[191,193,197,199,97]
|
paths=[191,193,197,199,97]
|
||||||
v = int(time.time()*1000000)
|
v = int(time.time()*1000000)
|
||||||
# b = name.encode('utf8') if not isinstance(name,bytes) else name
|
# b = name.encode('utf8') if not isinstance(name,bytes) else name
|
||||||
# v = int.from_bytes(b,byteorder='big',signed=False)
|
# v = int.from_bytes(b,byteorder='big',signed=False)
|
||||||
path = os.path.abspath(os.path.join(self.root,
|
path = os.path.abspath(os.path.join(self.root,
|
||||||
v % paths[0],
|
str(v % paths[0]),
|
||||||
v % paths[1],
|
str(v % paths[1]),
|
||||||
v % paths[2],
|
str(v % paths[2]),
|
||||||
v % paths[3],
|
str(v % paths[3]),
|
||||||
v % paths[4],
|
str(v % paths[4]),
|
||||||
name))
|
name))
|
||||||
return path
|
return path
|
||||||
|
|
||||||
async def save(name,read_data):
|
async def save(self,name,read_data):
|
||||||
p = self.name2path(name)
|
p = self._name2path(name)
|
||||||
_mkdir(os.path.dirname(p))
|
_mkdir(os.path.dirname(p))
|
||||||
async with aiofile.open(p,mode='rb') as f:
|
async with aiofile.AIOFile(p,'wb') as f:
|
||||||
while 1:
|
while 1:
|
||||||
d = await read_data()
|
d = await read_data()
|
||||||
if not d:
|
if not d:
|
||||||
break
|
break
|
||||||
await f.write(d)
|
await f.write(d)
|
||||||
|
await f.fsync()
|
||||||
|
|
||||||
return p[len(self.root):]
|
return p[len(self.root):]
|
||||||
|
@ -28,6 +28,7 @@ from .serverenv import ServerEnv
|
|||||||
from .url2file import Url2File
|
from .url2file import Url2File
|
||||||
from .filestorage import FileStorage
|
from .filestorage import FileStorage
|
||||||
from .restful import DBCrud
|
from .restful import DBCrud
|
||||||
|
from .filedownload import file_download, path_decode
|
||||||
|
|
||||||
def getHeaderLang(request):
|
def getHeaderLang(request):
|
||||||
al = request.headers.get('Accept-Language')
|
al = request.headers.get('Accept-Language')
|
||||||
@ -174,6 +175,14 @@ class ProcessorResource(StaticResource):
|
|||||||
id = pp[2]
|
id = pp[2]
|
||||||
crud = DBCrud(request,dbname,tablename,id=id)
|
crud = DBCrud(request,dbname,tablename,id=id)
|
||||||
return await crud.dispatch()
|
return await crud.dispatch()
|
||||||
|
if config.website.download and path.startswith(config.website.download):
|
||||||
|
pp = path.split('/')[2:]
|
||||||
|
if len(pp)<1:
|
||||||
|
raise HTTPNotFound
|
||||||
|
dp = '/'.join(pp)
|
||||||
|
path = path_decode(dp)
|
||||||
|
print('path=',path)
|
||||||
|
return await file_download(path)
|
||||||
|
|
||||||
for word, handlername in self.y_processors:
|
for word, handlername in self.y_processors:
|
||||||
if path.endswith(word):
|
if path.endswith(word):
|
||||||
|
Loading…
Reference in New Issue
Block a user