mirror of
https://github.com/9001/copyparty.git
synced 2025-10-03 09:49:29 +02:00
sqlite and misc optimizations:
* exponentially slow upload handshakes caused by lack of rd+fn sqlite index; became apparent after a volume hit 200k files * listing big folders 5% faster due to `_quotep3b` * optimize `unquote`, 20% faster but only used rarely * reindex on startup 150x faster in some rare cases (same filename in MANY folders) the database is now around 10% larger (likely worst-case)
This commit is contained in:
parent
2927bbb2d6
commit
d67e9cc507
5 changed files with 146 additions and 43 deletions
38
tests/test_utils.py
Normal file
38
tests/test_utils.py
Normal file
|
@ -0,0 +1,38 @@
|
|||
#!/usr/bin/env python3
|
||||
# coding: utf-8
|
||||
from __future__ import print_function, unicode_literals
|
||||
|
||||
import unittest
|
||||
|
||||
from copyparty.__main__ import PY2
|
||||
from copyparty.util import w8enc
|
||||
from tests import util as tu
|
||||
|
||||
|
||||
class TestUtils(unittest.TestCase):
|
||||
def cmp(self, orig, t1, t2):
|
||||
if t1 != t2:
|
||||
raise Exception("\n%r\n%r\n%r\n" % (w8enc(orig), t1, t2))
|
||||
|
||||
def test_quotep(self):
|
||||
if PY2:
|
||||
raise unittest.SkipTest()
|
||||
|
||||
from copyparty.util import _quotep3, _quotep3b, w8dec
|
||||
|
||||
txt = w8dec(tu.randbytes(8192))
|
||||
self.cmp(txt, _quotep3(txt), _quotep3b(txt))
|
||||
|
||||
def test_unquote(self):
|
||||
if PY2:
|
||||
raise unittest.SkipTest()
|
||||
|
||||
from urllib.parse import unquote_to_bytes as u2b
|
||||
|
||||
from copyparty.util import unquote
|
||||
|
||||
for btxt in (
|
||||
tu.randbytes(8192),
|
||||
br"%ed%91qw,er;ty%20as df?gh+jkl%zxc&vbn <qwe>\"rty'uio&asd fgh",
|
||||
):
|
||||
self.cmp(btxt, unquote(btxt), u2b(btxt))
|
Loading…
Add table
Add a link
Reference in a new issue