forked from Gardener/ShareX_Storage
misc and fixed issue after yaml api change
This commit is contained in:
parent
8475d15268
commit
ef3d829dba
@ -69,7 +69,7 @@ async def handle_upload(req, acc, acc_db):
|
|||||||
if h not in acc_db:
|
if h not in acc_db:
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
return web.Response(text='server full', status=500)
|
return web.Response(text='url key-space full', status=500)
|
||||||
|
|
||||||
acc_db[h] = filename
|
acc_db[h] = filename
|
||||||
local_fname = f'{conf.data_path}/{acc}/{h}_{filename}'
|
local_fname = f'{conf.data_path}/{acc}/{h}_{filename}'
|
||||||
@ -134,6 +134,17 @@ async def handle_download(req, acc, acc_db):
|
|||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
if conf.url_hash_len > 31:
|
||||||
|
raise ValueError('url_hash_len can\'t be bigger than 31')
|
||||||
|
if not set(conf.max_filesize.replace(' ', ''))\
|
||||||
|
.issubset(valid_hash_chars | {'*'}):
|
||||||
|
raise ValueError('max_filesize only can contain numbers and *')
|
||||||
|
conf.max_filesize = eval(conf.max_filesize)
|
||||||
|
conf.auth_tokens = set(conf.tokens)
|
||||||
|
conf.prefix = conf.prefix.strip("/")
|
||||||
|
if conf.prefix:
|
||||||
|
conf.prefix = f'/{conf.prefix}'
|
||||||
|
conf.del_crypt_key = hashlib.md5(conf.del_crypt_key.encode()).digest()[:16]
|
||||||
if not os.path.isdir(conf.data_path):
|
if not os.path.isdir(conf.data_path):
|
||||||
os.mkdir(conf.data_path)
|
os.mkdir(conf.data_path)
|
||||||
for acc in os.listdir(conf.data_path):
|
for acc in os.listdir(conf.data_path):
|
||||||
@ -157,16 +168,5 @@ if __name__ == '__main__':
|
|||||||
file_db = defaultdict(dict)
|
file_db = defaultdict(dict)
|
||||||
confname = sys.argv[1] if sys.argv[1:] and os.path.isfile(sys.argv[1]) else 'config.yaml'
|
confname = sys.argv[1] if sys.argv[1:] and os.path.isfile(sys.argv[1]) else 'config.yaml'
|
||||||
with open(confname) as cf:
|
with open(confname) as cf:
|
||||||
conf = AttrDict.from_dict_recur(yaml.load(cf))
|
conf = AttrDict.from_dict_recur(yaml.safe_load(cf))
|
||||||
if conf.url_hash_len > 31:
|
|
||||||
raise ValueError('url_hash_len can\'t be bigger than 31')
|
|
||||||
if not set(conf.max_filesize.replace(' ', ''))\
|
|
||||||
.issubset(valid_hash_chars | {'*'}):
|
|
||||||
raise ValueError('max_filsize only can contain numbers and *')
|
|
||||||
conf.max_filesize = eval(conf.max_filesize)
|
|
||||||
conf.auth_tokens = set(conf.tokens)
|
|
||||||
conf.prefix = conf.prefix.strip("/")
|
|
||||||
if conf.prefix:
|
|
||||||
conf.prefix = f'/{conf.prefix}'
|
|
||||||
conf.del_crypt_key = hashlib.md5(conf.del_crypt_key.encode()).digest()[:16]
|
|
||||||
main()
|
main()
|
||||||
|
Loading…
Reference in New Issue
Block a user