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.
Files changed (39) hide show
  1. {lfss-0.7.13 → lfss-0.7.14}/PKG-INFO +1 -1
  2. {lfss-0.7.13 → lfss-0.7.14}/frontend/index.html +1 -1
  3. {lfss-0.7.13 → lfss-0.7.14}/frontend/styles.css +0 -1
  4. lfss-0.7.14/frontend/thumb.css +10 -0
  5. {lfss-0.7.13 → lfss-0.7.14}/frontend/thumb.js +12 -5
  6. {lfss-0.7.13 → lfss-0.7.14}/lfss/src/server.py +14 -3
  7. {lfss-0.7.13 → lfss-0.7.14}/lfss/src/thumb.py +1 -0
  8. {lfss-0.7.13 → lfss-0.7.14}/pyproject.toml +1 -1
  9. lfss-0.7.13/frontend/thumb.css +0 -16
  10. {lfss-0.7.13 → lfss-0.7.14}/Readme.md +0 -0
  11. {lfss-0.7.13 → lfss-0.7.14}/docs/Known_issues.md +0 -0
  12. {lfss-0.7.13 → lfss-0.7.14}/docs/Permission.md +0 -0
  13. {lfss-0.7.13 → lfss-0.7.14}/frontend/api.js +0 -0
  14. {lfss-0.7.13 → lfss-0.7.14}/frontend/info.css +0 -0
  15. {lfss-0.7.13 → lfss-0.7.14}/frontend/info.js +0 -0
  16. {lfss-0.7.13 → lfss-0.7.14}/frontend/popup.css +0 -0
  17. {lfss-0.7.13 → lfss-0.7.14}/frontend/popup.js +0 -0
  18. {lfss-0.7.13 → lfss-0.7.14}/frontend/scripts.js +0 -0
  19. {lfss-0.7.13 → lfss-0.7.14}/frontend/utils.js +0 -0
  20. {lfss-0.7.13 → lfss-0.7.14}/lfss/cli/balance.py +0 -0
  21. {lfss-0.7.13 → lfss-0.7.14}/lfss/cli/cli.py +0 -0
  22. {lfss-0.7.13 → lfss-0.7.14}/lfss/cli/panel.py +0 -0
  23. {lfss-0.7.13 → lfss-0.7.14}/lfss/cli/serve.py +0 -0
  24. {lfss-0.7.13 → lfss-0.7.14}/lfss/cli/user.py +0 -0
  25. {lfss-0.7.13 → lfss-0.7.14}/lfss/cli/vacuum.py +0 -0
  26. {lfss-0.7.13 → lfss-0.7.14}/lfss/client/__init__.py +0 -0
  27. {lfss-0.7.13 → lfss-0.7.14}/lfss/client/api.py +0 -0
  28. {lfss-0.7.13 → lfss-0.7.14}/lfss/sql/init.sql +0 -0
  29. {lfss-0.7.13 → lfss-0.7.14}/lfss/sql/pragma.sql +0 -0
  30. {lfss-0.7.13 → lfss-0.7.14}/lfss/src/__init__.py +0 -0
  31. {lfss-0.7.13 → lfss-0.7.14}/lfss/src/bounded_pool.py +0 -0
  32. {lfss-0.7.13 → lfss-0.7.14}/lfss/src/config.py +0 -0
  33. {lfss-0.7.13 → lfss-0.7.14}/lfss/src/connection_pool.py +0 -0
  34. {lfss-0.7.13 → lfss-0.7.14}/lfss/src/database.py +0 -0
  35. {lfss-0.7.13 → lfss-0.7.14}/lfss/src/datatype.py +0 -0
  36. {lfss-0.7.13 → lfss-0.7.14}/lfss/src/error.py +0 -0
  37. {lfss-0.7.13 → lfss-0.7.14}/lfss/src/log.py +0 -0
  38. {lfss-0.7.13 → lfss-0.7.14}/lfss/src/stat.py +0 -0
  39. {lfss-0.7.13 → lfss-0.7.14}/lfss/src/utils.py +0 -0
@@ -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
@@ -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>
@@ -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;
@@ -0,0 +1,10 @@
1
+
2
+ div.thumb{
3
+ display: contents;
4
+ }
5
+ img.thumb{
6
+ height: 32px; /* smaller than backend */
7
+ width: 32px;
8
+ object-fit: contain;
9
+ border-radius: 0.1rem;
10
+ }
@@ -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
  `;
@@ -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 = {
@@ -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
  [tool.poetry]
2
2
  name = "lfss"
3
- version = "0.7.13"
3
+ version = "0.7.14"
4
4
  description = "Lightweight file storage service"
5
5
  authors = ["li, mengxun <limengxun45@outlook.com>"]
6
6
  readme = "Readme.md"
@@ -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