lfss 0.7.13__py3-none-any.whl → 0.7.14__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.
frontend/index.html CHANGED
@@ -30,7 +30,7 @@
30
30
  <label></label>
31
31
  </div>
32
32
  <div>
33
- <span style="margin-right: 0.25rem; color: #999;">
33
+ <span style="margin-right: 0.25rem; color: #999; font-size: small;">
34
34
  Sort by</span>
35
35
  <select id="sort-by-sel">
36
36
  <option value="none">None</option>
frontend/styles.css CHANGED
@@ -194,7 +194,6 @@ div.filename-container{
194
194
  flex-direction: row;
195
195
  align-items: center;
196
196
  gap: 0.5rem;
197
- height: 32px;
198
197
  }
199
198
  label#upload-file-prefix{
200
199
  width: 800px;
frontend/thumb.css CHANGED
@@ -1,16 +1,10 @@
1
1
 
2
2
  div.thumb{
3
- height: 32px;
4
- width: 32px;
5
- border-radius: 0.25rem;
6
3
  display: contents;
7
4
  }
8
5
  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);
6
+ height: 32px; /* smaller than backend */
7
+ width: 32px;
8
+ object-fit: contain;
9
+ border-radius: 0.1rem;
16
10
  }
frontend/thumb.js CHANGED
@@ -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
- 'text/x-python' || 'text/x-c' || 'text/x-c++' || 'text/x-java' || 'text/x-javascript' || 'text/x-php' || 'text/x-rust' || 'text/x-go' || 'text/x-csharp' || 'text/x-typescript' ||
39
- 'text/x-html' || 'text/x-css' || 'text/x-sql' || 'text/x-xml' || 'text/x-yaml' || 'text/x-json' || 'text/x-markdown' || 'text/x-shellscript' ||
40
- 'text/x-bat' || 'text/x-powershell' || 'text/x-bash' || 'text/x-perl' || 'text/x-ruby' || 'text/x-lua' || 'text/x-tcl' || 'text/x-lisp' ||
41
- 'text/x-haskell' || 'text/x-elm' || 'text/x-crystal' || 'text/x-nim' || 'text/x-zig':
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}/${r.url}?token=${token}&thumb=true" alt="${r.url}" class="thumb" \
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
  `;
lfss/src/server.py CHANGED
@@ -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
- raise HTTPException(status_code=415, detail="Thumbnail not supported")
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 = {
lfss/src/thumb.py CHANGED
@@ -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('''
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: lfss
3
- Version: 0.7.13
3
+ Version: 0.7.14
4
4
  Summary: Lightweight file storage service
5
5
  Home-page: https://github.com/MenxLi/lfss
6
6
  Author: li, mengxun
@@ -2,15 +2,15 @@ Readme.md,sha256=vsPotlwPAaHI5plh4aaszpi3rr7ZGDn7-wLdEYTWQ0k,1275
2
2
  docs/Known_issues.md,sha256=rfdG3j1OJF-59S9E06VPyn0nZKbW-ybPxkoZ7MEZWp8,81
3
3
  docs/Permission.md,sha256=X0VNfBKU52f93QYqcVyiBFJ3yURiSkhIo9S_5fdSgzM,2265
4
4
  frontend/api.js,sha256=o1sP4rKxxnM-rebxnlMlPkhPHzKaVW4kZC7B4ufbOK4,8026
5
- frontend/index.html,sha256=29btC2xxSaCBhZ4ozAlK-lC7Q4FcsuRgfAop3S9nBQ8,2844
5
+ frontend/index.html,sha256=i45ilkRCorqXP0bTfMiwT3QmmEF23V34lZJC1nODHLo,2862
6
6
  frontend/info.css,sha256=Ny0N3GywQ3a9q1_Qph_QFEKB4fEnTe_2DJ1Y5OsLLmQ,595
7
7
  frontend/info.js,sha256=WhOGaeqMoezEAfg4nIpK26hvejC7AZ-ZDLiJmRj0kDk,5758
8
8
  frontend/popup.css,sha256=TJZYFW1ZcdD1IVTlNPYNtMWKPbN6XDbQ4hKBOFK8uLg,1284
9
9
  frontend/popup.js,sha256=3PgaGZmxSdV1E-D_MWgcR7aHWkcsHA1BNKSOkmP66tA,5191
10
10
  frontend/scripts.js,sha256=hzX5kX2txIS3x2OLuYjrI3j-T5Na1M-_ktz4Rkxara4,22331
11
- frontend/styles.css,sha256=Xl8FTDS32DQ_dLVX-UIgvAVJlKx8csYEyeNFX5o1eUY,4502
12
- frontend/thumb.css,sha256=uVTt-8gDdgNiNmqJnsTVK1gvixEUabM2SRd3Ed_0Kag,319
13
- frontend/thumb.js,sha256=m0-Nip5bgtipdBz1GtRBk-0aaJ-4wKhlT9rEN_0oBh8,4881
11
+ frontend/styles.css,sha256=krMo6Ulroi8pqEq1exQsFEU-FJqT9GzI8vyARiNF11k,4484
12
+ frontend/thumb.css,sha256=1i8wudiMWGwdrnTqs6yrS8YaiPeHPR-A2YqUNJN20Ok,165
13
+ frontend/thumb.js,sha256=MFAr_gOB-L4Su7JsnR8sy9TqP2oHR31AJAWi8nH4bXg,5296
14
14
  frontend/utils.js,sha256=IYUZl77ugiXKcLxSNOWC4NSS0CdD5yRgUsDb665j0xM,2556
15
15
  lfss/cli/balance.py,sha256=R2rbO2tg9TVnnQIVeU0GJVeMS-5LDhEdk4mbOE9qGq0,4121
16
16
  lfss/cli/cli.py,sha256=LH1nx5wI1K2DZ3hvHz7oq5HcXVDoW2V6sr7q9gJ8gqo,4621
@@ -30,11 +30,11 @@ lfss/src/database.py,sha256=w2QPE3h1Lx0D0fUmdtu9s1XHpNp9p27zqm8AVeP2UVg,32476
30
30
  lfss/src/datatype.py,sha256=WfrLALU_7wei5-i_b0TxY8xWI5mwxLUHFepHSps49zA,1767
31
31
  lfss/src/error.py,sha256=imbhwnbhnI3HLhkbfICROe3F0gleKrOk4XnqHJDOtuI,285
32
32
  lfss/src/log.py,sha256=u6WRZZsE7iOx6_CV2NHh1ugea26p408FI4WstZh896A,5139
33
- lfss/src/server.py,sha256=d5PdRXR2LefvbVpBk7qC-MCBXP_Z3hGL_vBceSznpw4,17344
33
+ lfss/src/server.py,sha256=igkPC3gdJoIqcVTKBAKkVPRrclXR2ZNBdRIAEci4xMo,17717
34
34
  lfss/src/stat.py,sha256=Wr-ug_JqtbSIf3XwQnv1xheGhsDTEOlLWuYoKO_26Jo,3201
35
- lfss/src/thumb.py,sha256=QhFmPCBZ5fDwtNC07kt-PKttDVNtx2x0HFXphORlkes,3028
35
+ lfss/src/thumb.py,sha256=Ml4vQEWK3R-tVAAFDt6GZUteZBUM1Q0QPVtU1zn7G44,3111
36
36
  lfss/src/utils.py,sha256=TBGYvgt6xMP8UC5wTGHAr9fmdhu0_gjOtxcSeyvGyVM,3918
37
- lfss-0.7.13.dist-info/METADATA,sha256=M5e-IMIsEuQaVHXwm3osFRM-yzdk6PDod6uTZnImyVI,2021
38
- lfss-0.7.13.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
39
- lfss-0.7.13.dist-info/entry_points.txt,sha256=VJ8svMz7RLtMCgNk99CElx7zo7M-N-z7BWDVw2HA92E,205
40
- lfss-0.7.13.dist-info/RECORD,,
37
+ lfss-0.7.14.dist-info/METADATA,sha256=ol6x7IVBcz2KtNZPPXULNiW_sztyuNvm3osrAkq4_Lk,2021
38
+ lfss-0.7.14.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
39
+ lfss-0.7.14.dist-info/entry_points.txt,sha256=VJ8svMz7RLtMCgNk99CElx7zo7M-N-z7BWDVw2HA92E,205
40
+ lfss-0.7.14.dist-info/RECORD,,
File without changes