lfss 0.7.13__tar.gz → 0.7.14__tar.gz
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-0.7.13 → lfss-0.7.14}/PKG-INFO +1 -1
- {lfss-0.7.13 → lfss-0.7.14}/frontend/index.html +1 -1
- {lfss-0.7.13 → lfss-0.7.14}/frontend/styles.css +0 -1
- lfss-0.7.14/frontend/thumb.css +10 -0
- {lfss-0.7.13 → lfss-0.7.14}/frontend/thumb.js +12 -5
- {lfss-0.7.13 → lfss-0.7.14}/lfss/src/server.py +14 -3
- {lfss-0.7.13 → lfss-0.7.14}/lfss/src/thumb.py +1 -0
- {lfss-0.7.13 → lfss-0.7.14}/pyproject.toml +1 -1
- lfss-0.7.13/frontend/thumb.css +0 -16
- {lfss-0.7.13 → lfss-0.7.14}/Readme.md +0 -0
- {lfss-0.7.13 → lfss-0.7.14}/docs/Known_issues.md +0 -0
- {lfss-0.7.13 → lfss-0.7.14}/docs/Permission.md +0 -0
- {lfss-0.7.13 → lfss-0.7.14}/frontend/api.js +0 -0
- {lfss-0.7.13 → lfss-0.7.14}/frontend/info.css +0 -0
- {lfss-0.7.13 → lfss-0.7.14}/frontend/info.js +0 -0
- {lfss-0.7.13 → lfss-0.7.14}/frontend/popup.css +0 -0
- {lfss-0.7.13 → lfss-0.7.14}/frontend/popup.js +0 -0
- {lfss-0.7.13 → lfss-0.7.14}/frontend/scripts.js +0 -0
- {lfss-0.7.13 → lfss-0.7.14}/frontend/utils.js +0 -0
- {lfss-0.7.13 → lfss-0.7.14}/lfss/cli/balance.py +0 -0
- {lfss-0.7.13 → lfss-0.7.14}/lfss/cli/cli.py +0 -0
- {lfss-0.7.13 → lfss-0.7.14}/lfss/cli/panel.py +0 -0
- {lfss-0.7.13 → lfss-0.7.14}/lfss/cli/serve.py +0 -0
- {lfss-0.7.13 → lfss-0.7.14}/lfss/cli/user.py +0 -0
- {lfss-0.7.13 → lfss-0.7.14}/lfss/cli/vacuum.py +0 -0
- {lfss-0.7.13 → lfss-0.7.14}/lfss/client/__init__.py +0 -0
- {lfss-0.7.13 → lfss-0.7.14}/lfss/client/api.py +0 -0
- {lfss-0.7.13 → lfss-0.7.14}/lfss/sql/init.sql +0 -0
- {lfss-0.7.13 → lfss-0.7.14}/lfss/sql/pragma.sql +0 -0
- {lfss-0.7.13 → lfss-0.7.14}/lfss/src/__init__.py +0 -0
- {lfss-0.7.13 → lfss-0.7.14}/lfss/src/bounded_pool.py +0 -0
- {lfss-0.7.13 → lfss-0.7.14}/lfss/src/config.py +0 -0
- {lfss-0.7.13 → lfss-0.7.14}/lfss/src/connection_pool.py +0 -0
- {lfss-0.7.13 → lfss-0.7.14}/lfss/src/database.py +0 -0
- {lfss-0.7.13 → lfss-0.7.14}/lfss/src/datatype.py +0 -0
- {lfss-0.7.13 → lfss-0.7.14}/lfss/src/error.py +0 -0
- {lfss-0.7.13 → lfss-0.7.14}/lfss/src/log.py +0 -0
- {lfss-0.7.13 → lfss-0.7.14}/lfss/src/stat.py +0 -0
- {lfss-0.7.13 → lfss-0.7.14}/lfss/src/utils.py +0 -0
@@ -35,10 +35,10 @@ function getIconSVGFromMimeType(mimeType){
|
|
35
35
|
'application/zip' || 'application/x-zip-compressed' || 'application/x-7z-compressed' || 'application/x-rar-compressed' || 'application/x-tar' || 'application/x-gzip':
|
36
36
|
return ICON_ZIP;
|
37
37
|
case
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
38
|
+
"text/html" || "application/xhtml+xml" || "application/xml" || "text/css" || "application/javascript" || "text/javascript" || "application/json" || "text/x-python" || "text/x-java-source" ||
|
39
|
+
"application/x-httpd-php" || "text/x-ruby" || "text/x-perl" || "application/x-sh" || "application/sql" || "text/x-csrc" || "text/x-c++src" || "text/x-csharp" || "text/x-go" || "text/x-haskell" ||
|
40
|
+
"text/x-lua" || "text/x-markdown" || "application/wasm" || "application/x-tcl" || "text/x-yaml" || "application/x-latex" || "application/x-tex" || "text/x-scss" || "application/x-lisp" ||
|
41
|
+
"application/x-rustsrc" || "application/x-ruby" || "text/x-asm":
|
42
42
|
return ICON_CODE;
|
43
43
|
default:
|
44
44
|
return ICON_FILE;
|
@@ -46,6 +46,11 @@ function getIconSVGFromMimeType(mimeType){
|
|
46
46
|
}
|
47
47
|
|
48
48
|
function getSafeIconUrl(icon_str){
|
49
|
+
// change icon color
|
50
|
+
const color = '#345';
|
51
|
+
icon_str = icon_str
|
52
|
+
.replace(/<svg/, `<svg fill="${color}"`)
|
53
|
+
.replace(/<path/, `<path fill="${color}"`);
|
49
54
|
return 'data:image/svg+xml,' + encodeURIComponent(icon_str);
|
50
55
|
}
|
51
56
|
|
@@ -56,12 +61,14 @@ let thumb_counter = 0;
|
|
56
61
|
* @returns {string}
|
57
62
|
*/
|
58
63
|
export function makeThumbHtml(c, r){
|
64
|
+
function ensureSlashEnd(url){ return url.endsWith('/')? url : url + '/'; }
|
59
65
|
const token = c.config.token;
|
60
66
|
const mtype = r.mime_type? r.mime_type : 'directory';
|
61
67
|
const thumb_id = `thumb-${thumb_counter++}`;
|
68
|
+
const url = mtype == 'directory'? ensureSlashEnd(r.url) : r.url;
|
62
69
|
return `
|
63
70
|
<div class="thumb" id="${thumb_id}"> \
|
64
|
-
<img src="${c.config.endpoint}/${
|
71
|
+
<img src="${c.config.endpoint}/${url}?token=${token}&thumb=true" alt="${r.url}" class="thumb" \
|
65
72
|
onerror="this.src='${getSafeIconUrl(getIconSVGFromMimeType(mtype))}';this.classList.add('thumb-svg');" \
|
66
73
|
</div>
|
67
74
|
`;
|
@@ -101,9 +101,11 @@ async def log_requests(request: Request, call_next):
|
|
101
101
|
response_time = end_time - start_time
|
102
102
|
response.headers["X-Response-Time"] = str(response_time)
|
103
103
|
|
104
|
+
if response.headers.get("X-Skip-Log", None) is not None:
|
105
|
+
return response
|
106
|
+
|
104
107
|
if response.status_code >= 400:
|
105
108
|
logger_failed_request.error(f"{request.method} {request.url.path} {response.status_code}")
|
106
|
-
|
107
109
|
await req_conn.log_request(
|
108
110
|
request_time_stamp,
|
109
111
|
request.method, request.url.path, response.status_code, response_time,
|
@@ -114,11 +116,20 @@ async def log_requests(request: Request, call_next):
|
|
114
116
|
response_size = int(response.headers.get("Content-Length", 0))
|
115
117
|
)
|
116
118
|
await req_conn.ensure_commit_once()
|
117
|
-
|
118
119
|
return response
|
119
120
|
|
121
|
+
def skip_request_log(fn):
|
122
|
+
@wraps(fn)
|
123
|
+
async def wrapper(*args, **kwargs):
|
124
|
+
response = await fn(*args, **kwargs)
|
125
|
+
assert isinstance(response, Response), "Response expected"
|
126
|
+
response.headers["X-Skip-Log"] = "1"
|
127
|
+
return response
|
128
|
+
return wrapper
|
129
|
+
|
120
130
|
router_fs = APIRouter(prefix="")
|
121
131
|
|
132
|
+
@skip_request_log
|
122
133
|
async def emit_thumbnail(
|
123
134
|
path: str, download: bool,
|
124
135
|
create_time: Optional[str] = None
|
@@ -128,7 +139,7 @@ async def emit_thumbnail(
|
|
128
139
|
else:
|
129
140
|
fname = path.split("/")[-1]
|
130
141
|
if (thumb_res := await get_thumb(path)) is None:
|
131
|
-
|
142
|
+
return Response(status_code=415, content="Thumbnail not supported")
|
132
143
|
thumb_blob, mime_type = thumb_res
|
133
144
|
disp = "inline" if not download else "attachment"
|
134
145
|
headers = {
|
@@ -14,6 +14,7 @@ async def _maybe_init_thumb(c: aiosqlite.Cursor):
|
|
14
14
|
thumb BLOB
|
15
15
|
)
|
16
16
|
''')
|
17
|
+
await c.execute('CREATE INDEX IF NOT EXISTS thumbs_path_idx ON thumbs (path)')
|
17
18
|
|
18
19
|
async def _get_cache_thumb(c: aiosqlite.Cursor, path: str, ctime: str) -> Optional[bytes]:
|
19
20
|
res = await c.execute('''
|
lfss-0.7.13/frontend/thumb.css
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
|
2
|
-
div.thumb{
|
3
|
-
height: 32px;
|
4
|
-
width: 32px;
|
5
|
-
border-radius: 0.25rem;
|
6
|
-
display: contents;
|
7
|
-
}
|
8
|
-
img.thumb{
|
9
|
-
max-height: 32px; /* smaller than backend */
|
10
|
-
max-width: 32px;
|
11
|
-
border-radius: 0.25rem;
|
12
|
-
}
|
13
|
-
img.thumb-svg{
|
14
|
-
/* dark blue */
|
15
|
-
filter: invert(30%) sepia(100%) saturate(80%) hue-rotate(180deg);
|
16
|
-
}
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|