lfss 0.7.10__py3-none-any.whl → 0.7.11__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- lfss/cli/serve.py +1 -1
- lfss/cli/vacuum.py +6 -8
- lfss/src/server.py +0 -1
- lfss/src/stat.py +10 -2
- {lfss-0.7.10.dist-info → lfss-0.7.11.dist-info}/METADATA +2 -1
- {lfss-0.7.10.dist-info → lfss-0.7.11.dist-info}/RECORD +8 -8
- {lfss-0.7.10.dist-info → lfss-0.7.11.dist-info}/WHEEL +0 -0
- {lfss-0.7.10.dist-info → lfss-0.7.11.dist-info}/entry_points.txt +0 -0
lfss/cli/serve.py
CHANGED
@@ -24,7 +24,7 @@ def main():
|
|
24
24
|
log_config=default_logging_config
|
25
25
|
)
|
26
26
|
server = Server(config=config)
|
27
|
-
logger.info(f"Starting server at {args.host}:{args.port}, with {args.workers} workers")
|
27
|
+
logger.info(f"Starting server at http://{args.host}:{args.port}, with {args.workers} workers.")
|
28
28
|
server.run()
|
29
29
|
|
30
30
|
if __name__ == "__main__":
|
lfss/cli/vacuum.py
CHANGED
@@ -2,8 +2,8 @@
|
|
2
2
|
Vacuum the database and external storage to ensure that the storage is consistent and minimal.
|
3
3
|
"""
|
4
4
|
|
5
|
-
from lfss.src.config import LARGE_BLOB_DIR
|
6
|
-
import argparse, time
|
5
|
+
from lfss.src.config import LARGE_BLOB_DIR
|
6
|
+
import argparse, time
|
7
7
|
from functools import wraps
|
8
8
|
from asyncio import Semaphore
|
9
9
|
import aiofiles, asyncio
|
@@ -11,6 +11,7 @@ import aiofiles.os
|
|
11
11
|
from contextlib import contextmanager
|
12
12
|
from lfss.src.database import transaction, unique_cursor
|
13
13
|
from lfss.src.stat import RequestDB
|
14
|
+
from lfss.src.utils import now_stamp
|
14
15
|
from lfss.src.connection_pool import global_entrance
|
15
16
|
|
16
17
|
sem: Semaphore
|
@@ -68,12 +69,9 @@ async def vacuum_main(index: bool = False, blobs: bool = False):
|
|
68
69
|
|
69
70
|
async def vacuum_requests():
|
70
71
|
with indicator("VACUUM-requests"):
|
71
|
-
|
72
|
-
|
73
|
-
await req_db.shrink()
|
72
|
+
async with RequestDB().connect() as req_db:
|
73
|
+
await req_db.shrink(max_rows=1_000_000, time_before=now_stamp() - 7*24*60*60)
|
74
74
|
await req_db.conn.execute("VACUUM")
|
75
|
-
finally:
|
76
|
-
await req_db.close()
|
77
75
|
|
78
76
|
def main():
|
79
77
|
global sem
|
@@ -81,7 +79,7 @@ def main():
|
|
81
79
|
parser.add_argument("-j", "--jobs", type=int, default=2, help="Number of concurrent jobs")
|
82
80
|
parser.add_argument("-m", "--metadata", action="store_true", help="Vacuum metadata")
|
83
81
|
parser.add_argument("-d", "--data", action="store_true", help="Vacuum blobs")
|
84
|
-
parser.add_argument("-r", "--requests", action="store_true", help="Vacuum request logs")
|
82
|
+
parser.add_argument("-r", "--requests", action="store_true", help="Vacuum request logs to only keep at most recent 1M rows in 7 days")
|
85
83
|
args = parser.parse_args()
|
86
84
|
sem = Semaphore(args.jobs)
|
87
85
|
asyncio.run(vacuum_main(index=args.metadata, blobs=args.data))
|
lfss/src/server.py
CHANGED
lfss/src/stat.py
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
from typing import Optional, Any
|
2
2
|
import aiosqlite
|
3
|
+
from contextlib import asynccontextmanager
|
3
4
|
from .config import DATA_HOME
|
4
|
-
from .utils import debounce_async
|
5
|
+
from .utils import debounce_async
|
5
6
|
|
6
7
|
class RequestDB:
|
7
8
|
conn: aiosqlite.Connection
|
@@ -26,6 +27,14 @@ class RequestDB:
|
|
26
27
|
)
|
27
28
|
''')
|
28
29
|
return self
|
30
|
+
|
31
|
+
def connect(self):
|
32
|
+
@asynccontextmanager
|
33
|
+
async def _mgr():
|
34
|
+
await self.init()
|
35
|
+
yield self
|
36
|
+
await self.close()
|
37
|
+
return _mgr()
|
29
38
|
|
30
39
|
async def close(self):
|
31
40
|
await self.conn.close()
|
@@ -65,7 +74,6 @@ class RequestDB:
|
|
65
74
|
assert cursor.lastrowid is not None
|
66
75
|
return cursor.lastrowid
|
67
76
|
|
68
|
-
@concurrent_wrap()
|
69
77
|
async def shrink(self, max_rows: int = 1_000_000, time_before: float = 0):
|
70
78
|
async with aiosqlite.connect(self.db) as conn:
|
71
79
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: lfss
|
3
|
-
Version: 0.7.
|
3
|
+
Version: 0.7.11
|
4
4
|
Summary: Lightweight file storage service
|
5
5
|
Home-page: https://github.com/MenxLi/lfss
|
6
6
|
Author: li, mengxun
|
@@ -15,6 +15,7 @@ Requires-Dist: aiofiles (==23.*)
|
|
15
15
|
Requires-Dist: aiosqlite (==0.*)
|
16
16
|
Requires-Dist: fastapi (==0.*)
|
17
17
|
Requires-Dist: mimesniff (==1.*)
|
18
|
+
Requires-Dist: uvicorn (==0.*)
|
18
19
|
Project-URL: Repository, https://github.com/MenxLi/lfss
|
19
20
|
Description-Content-Type: text/markdown
|
20
21
|
|
@@ -13,9 +13,9 @@ frontend/utils.js,sha256=Ts4nlef8pkrEgpwX-uQwAhWvwxlIzex8ijDLNCa22ps,2372
|
|
13
13
|
lfss/cli/balance.py,sha256=R2rbO2tg9TVnnQIVeU0GJVeMS-5LDhEdk4mbOE9qGq0,4121
|
14
14
|
lfss/cli/cli.py,sha256=LH1nx5wI1K2DZ3hvHz7oq5HcXVDoW2V6sr7q9gJ8gqo,4621
|
15
15
|
lfss/cli/panel.py,sha256=iGdVmdWYjA_7a78ZzWEB_3ggIOBeUKTzg6F5zLaB25c,1401
|
16
|
-
lfss/cli/serve.py,sha256=
|
16
|
+
lfss/cli/serve.py,sha256=T-jz_PJcaY9FJRRfyWV9MbjDI73YdOOCn4Nr2PO-s0c,993
|
17
17
|
lfss/cli/user.py,sha256=ETLtj0N-kmxv0mhmeAsO6cY7kPq7nOOP4DetxIRoQpQ,3405
|
18
|
-
lfss/cli/vacuum.py,sha256=
|
18
|
+
lfss/cli/vacuum.py,sha256=4TMMYC_5yEt7jeaFTVC3iX0X6aUzYXBiCsrcIYgw_uA,3695
|
19
19
|
lfss/client/__init__.py,sha256=8uvcKs3PYQamDd_cjfN-fX9QUohEzJqeJlOYkBlzC3M,4556
|
20
20
|
lfss/client/api.py,sha256=kSkB4wADTu012-1wl6v90OiZrw6aTQ42GU4jtV4KO0k,5764
|
21
21
|
lfss/sql/init.sql,sha256=C-JtQAlaOjESI8uoF1Y_9dKukEVSw5Ll-7yA3gG-XHU,1210
|
@@ -27,10 +27,10 @@ lfss/src/database.py,sha256=w2QPE3h1Lx0D0fUmdtu9s1XHpNp9p27zqm8AVeP2UVg,32476
|
|
27
27
|
lfss/src/datatype.py,sha256=WfrLALU_7wei5-i_b0TxY8xWI5mwxLUHFepHSps49zA,1767
|
28
28
|
lfss/src/error.py,sha256=imbhwnbhnI3HLhkbfICROe3F0gleKrOk4XnqHJDOtuI,285
|
29
29
|
lfss/src/log.py,sha256=u6WRZZsE7iOx6_CV2NHh1ugea26p408FI4WstZh896A,5139
|
30
|
-
lfss/src/server.py,sha256=
|
31
|
-
lfss/src/stat.py,sha256=
|
30
|
+
lfss/src/server.py,sha256=pz5cAofW0Ge_xj9ceht5IEJ04bvFTgiwv0ESX6qHoJU,16256
|
31
|
+
lfss/src/stat.py,sha256=Wr-ug_JqtbSIf3XwQnv1xheGhsDTEOlLWuYoKO_26Jo,3201
|
32
32
|
lfss/src/utils.py,sha256=TBGYvgt6xMP8UC5wTGHAr9fmdhu0_gjOtxcSeyvGyVM,3918
|
33
|
-
lfss-0.7.
|
34
|
-
lfss-0.7.
|
35
|
-
lfss-0.7.
|
36
|
-
lfss-0.7.
|
33
|
+
lfss-0.7.11.dist-info/METADATA,sha256=9GmBltFBPJ8jFEo2QtVd5FbSILGbKf4HECzm4orTolI,1999
|
34
|
+
lfss-0.7.11.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
35
|
+
lfss-0.7.11.dist-info/entry_points.txt,sha256=VJ8svMz7RLtMCgNk99CElx7zo7M-N-z7BWDVw2HA92E,205
|
36
|
+
lfss-0.7.11.dist-info/RECORD,,
|
File without changes
|
File without changes
|